[style] rustfmt matches with comments in or-patterns#156518
Conversation
Using rust-lang/rustfmt#6893, reformat the codebase. The result is that matches that *would have* been formatted under normal circumstances get their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR. Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime.
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Thanks VSCode!
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer The Clippy subtree was changed cc @rust-lang/clippy The Miri subtree was changed cc @rust-lang/miri The run-make-support library was changed cc @jieyouxu |
| // assigning to P[i] requires P to be valid. | ||
| ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) => | ||
| // assigning to (P->variant) is okay if assigning to `P` is okay | ||
| // | ||
| // FIXME: is this true even if P is an adt with a dtor? | ||
| { } | ||
| // assigning to (P->variant) is okay if assigning to `P` is okay | ||
| // | ||
| // FIXME: is this true even if P is an adt with a dtor? | ||
| {} |
There was a problem hiding this comment.
Are all these and the P[i] comments in the right place? Looks like they're below the arms they're talking about.
There was a problem hiding this comment.
I moved them around to where I think they belong (both comments were shifted one down).
| | ty::PredicateKind::ConstEquate { .. } | ||
| // Ambiguous predicates should never error | ||
| | ty::PredicateKind::Ambiguous | ||
| // We never return Err when proving UnstableFeature goal. |
There was a problem hiding this comment.
Why did all these comments move up? 🤔 I don't think that's a good thing.
There was a problem hiding this comment.
I moved them manually so that their formatting will continue being checked until rustfmt is fixed. Tried to keep that to a minimum.
There was a problem hiding this comment.
Note that this is one of the most impacted files, as it has quite a big match expression, which means that the likelihood of formatting regressing in this match are high.
|
|
||
| mir::Rvalue::BinaryOp(op, (ref lhs, ref rhs)) => { |
There was a problem hiding this comment.
Are the extra blank lines manual or did rustfmt do this? Here and elsewhere.
There was a problem hiding this comment.
I believe these were manual. I did that once to keep consistency throughout a single match expression.
This comment has been minimized.
This comment has been minimized.
[style] rustfmt `match`es with comments in or-patterns Using rust-lang/rustfmt#6893, I reformatted the whole codebase. The result is that `match`es that *should have* been formatted under normal circumstances but are getting skipped now got their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR. Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime. (Introduced and) removed a bunch of stray backticks \` likely left after an editor autoclosed the intended closing \`, resulting in <code>\`name\`\`</code> in comments.
|
💔 Test for d09436f failed: CI. Failed job:
|
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
[style] rustfmt `match`es with comments in or-patterns Using rust-lang/rustfmt#6893, I reformatted the whole codebase. The result is that `match`es that *should have* been formatted under normal circumstances but are getting skipped now got their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR. Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime. (Introduced and) removed a bunch of stray backticks \` likely left after an editor autoclosed the intended closing \`, resulting in <code>\`name\`\`</code> in comments.
Rollup of 6 pull requests Successful merges: - #152852 (Remove driver_lint_caps) - #156121 (compiler: suggest `.collect()` when `String` is expected and `Iterator` is found) - #156518 ([style] rustfmt `match`es with comments in or-patterns) - #156596 (Split `LintExpectationId`s) - #156577 (Test EII UI tests with prefer-dynamic) - #156633 (Add regression test for issue #41261)
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing d3cd040 (parent) -> 281c97c (this PR) Test differencesShow 110 test diffs110 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 281c97c3240a9abd984ca0c6a2cd7389115e80d5 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Using rust-lang/rustfmt#6893, I reformatted the whole codebase. The result is that
matches that should have been formatted under normal circumstances but are getting skipped now got their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR.Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime.
(Introduced and) removed a bunch of stray backticks ` likely left after an editor autoclosed the intended closing `, resulting in
`name``in comments.