Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collect_tokens_trailing_token cleanups #127902

Merged

Commits on Jul 19, 2024

  1. Simplify CaptureState::inner_attr_ranges.

    The `Option`s within the `ReplaceRange`s within the hashmap are always
    `None`. This PR omits them and inserts them when they are extracted from
    the hashmap.
    nnethercote committed Jul 19, 2024
    Configuration menu
    Copy the full SHA
    757f73f View commit details
    Browse the repository at this point in the history
  2. Remove final_attrs local variable.

    It's no shorter than `ret.attrs()`, and `ret.attrs()` is used multiple
    times earlier in the function.
    nnethercote committed Jul 19, 2024
    Configuration menu
    Copy the full SHA
    1f67cf9 View commit details
    Browse the repository at this point in the history
  3. Move inner_attr code downwards.

    This puts it just before the `replace_ranges` initialization, which
    makes sense because the two variables are closely related.
    nnethercote committed Jul 19, 2024
    Configuration menu
    Copy the full SHA
    f9c7ca7 View commit details
    Browse the repository at this point in the history
  4. Make Parser::num_bump_calls 0-indexed.

    Currently in `collect_tokens_trailing_token`, `start_pos` and `end_pos`
    are 1-indexed by `replace_ranges` is 0-indexed, which is really
    confusing. Making them both 0-indexed makes debugging much easier.
    nnethercote committed Jul 19, 2024
    Configuration menu
    Copy the full SHA
    ca66495 View commit details
    Browse the repository at this point in the history
  5. Overhaul comments in collect_tokens_trailing_token.

    Adding details, clarifying lots of little things, etc. In particular,
    the commit adds details of an example. I find this very helpful, because
    it's taken me a long time to understand how this code works.
    nnethercote committed Jul 19, 2024
    Configuration menu
    Copy the full SHA
    1dd566a View commit details
    Browse the repository at this point in the history