Skip to content

Fix skip range miscalculation - #7049

Open
matthewhughes934 wants to merge 2 commits into
rust-lang:mainfrom
matthewhughes934:fix-skips-pre-work
Open

Fix skip range miscalculation#7049
matthewhughes934 wants to merge 2 commits into
rust-lang:mainfrom
matthewhughes934:fix-skips-pre-work

Conversation

@matthewhughes934

Copy link
Copy Markdown
Contributor

As well as a bit of code tidying

  • Idempotent test: avoid redundant file reads

    We read the 'significant comments' in check_files, so just pass it
    down rather than re-reading the test file.

  • Fix skip range miscalculated on nested blocks

    Fix a bug in FmtVisitor::push_skipped_with_span that assumed
    line_number was always absolute (within a given file) and instead set
    the end of the range to be the end of the span with the skip attribute.

    Found while investigating issue rustfmt::skip sometimes ignored when using error_on_line_overflow and error_on_unformatted #6954 (but this commit doesn't address
    that issue).

We read the 'significant comments' in `check_files`, so just pass it
down rather than re-reading the test file.
Fix a bug in `FmtVisitor::push_skipped_with_span` that assumed
`line_number` was always absolute (within a given file) and instead set
the end of the range to be the end of the span with the skip attribute.

Found while investigating issue rust-lang#6954 (but this commit doesn't address
that issue).
@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants