Skip to content

[style] rustfmt matches with comments in or-patterns#156518

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
estebank:match-rustfmt
May 17, 2026
Merged

[style] rustfmt matches with comments in or-patterns#156518
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
estebank:match-rustfmt

Conversation

@estebank
Copy link
Copy Markdown
Contributor

@estebank estebank commented May 13, 2026

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.

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.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 13, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 13, 2026

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, types
  • compiler, types expanded to 73 candidates
  • Random selection from 17 candidates

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 13, 2026

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

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs T-clippy Relevant to the Clippy team. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels May 13, 2026
Copy link
Copy Markdown
Contributor

@mejrs mejrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 2245 to +2250
// 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?
{}
Copy link
Copy Markdown
Contributor

@mejrs mejrs May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these and the P[i] comments in the right place? Looks like they're below the arms they're talking about.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did all these comments move up? 🤔 I don't think that's a good thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved them manually so that their formatting will continue being checked until rustfmt is fixed. Tried to keep that to a minimum.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +563 to 564

mir::Rvalue::BinaryOp(op, (ref lhs, ref rhs)) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the extra blank lines manual or did rustfmt do this? Here and elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these were manual. I did that once to keep consistency throughout a single match expression.

@rustbot rustbot assigned mejrs and unassigned wesleywiser May 15, 2026
Copy link
Copy Markdown
Contributor

@mejrs mejrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 16, 2026

📌 Commit 5cd51c0 has been approved by mejrs

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 16, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 16, 2026
[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.
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 16, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 16, 2026

💔 Test for d09436f failed: CI. Failed job:

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

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)
#13 DONE 23.3s

#14 [ 6/25] RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
#14 0.164 Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
#14 0.182 Executing: /tmp/apt-key-gpghome.eJ8S2cwtYf/gpg.1.sh --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7924C5513486
#14 0.815 gpg: key 74DA7924C5513486: public key "Igor Kozhukhov <igor@dilos.org>" imported
#14 0.819 gpg: Total number processed: 1
#14 0.819 gpg:               imported: 1
#14 DONE 0.9s

@Kobzol
Copy link
Copy Markdown
Member

Kobzol commented May 16, 2026

@bors retry

Spurious failure fixed by #156640.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 16, 2026
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 16, 2026
[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.
rust-bors Bot pushed a commit that referenced this pull request May 16, 2026
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)
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 17, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 17, 2026

☀️ Test successful - CI
Approved by: mejrs
Duration: 3h 17m 3s
Pushing 281c97c to main...

@rust-bors rust-bors Bot merged commit 281c97c into rust-lang:main May 17, 2026
12 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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 differences

Show 110 test diffs

110 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 281c97c3240a9abd984ca0c6a2cd7389115e80d5 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-ohos-x86_64: 1h 3m -> 1h 20m (+27.5%)
  2. dist-ohos-aarch64: 1h 3m -> 1h 20m (+27.4%)
  3. dist-armhf-linux: 1h 11m -> 1h 31m (+27.1%)
  4. dist-riscv64-linux: 1h 12m -> 1h 29m (+23.5%)
  5. dist-i686-mingw: 2h 48m -> 2h 11m (-22.1%)
  6. dist-i686-msvc: 2h 26m -> 1h 54m (-22.1%)
  7. dist-x86_64-mingw: 2h 40m -> 2h 6m (-21.1%)
  8. dist-various-2: 35m 54s -> 42m 40s (+18.8%)
  9. optional-x86_64-gnu-parallel-frontend: 2h 22m -> 2h 48m (+18.8%)
  10. dist-arm-linux-gnueabi: 1h 30m -> 1h 13m (-18.5%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs merged-by-bors This PR was explicitly merged by bors. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants