Skip to content

Fix diagnostics str::replace comma to bar #143331

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented Jul 2, 2025

Fix #143330

@rustbot
Copy link
Collaborator

rustbot commented Jul 2, 2025

r? @compiler-errors

rustbot has assigned @compiler-errors.
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

@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 Jul 2, 2025
@folkertdev
Copy link
Contributor

You should probably add a test in tests/ui/parser/ with the input from the issue, and run ./x test tests/ui/parser --bless to get the error output in a .stderr file. That way, this message won't regress in the future.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens/issue-48492-tuple-destructure-missing-parens.stderr`
diff of stderr:

32    |
33 LL |         (Nucleotide::Adenine, Nucleotide::Cytosine, _) => true
34    |         +                                            +
- help: ...or a vertical bar to match on multiple alternatives
+ help: ...or a vertical bar to match on alternative
36    |
37 LL -         Nucleotide::Adenine, Nucleotide::Cytosine, _ => true
- LL +         Nucleotide::Adenine | Nucleotide::Cytosine | _ => true
+ LL +         Nucleotide::Adenine | Nucleotide::Cytosine, _ => true
39    |
40 
41 error: unexpected `,` in pattern


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args did_you_mean/issue-48492-tuple-destructure-missing-parens.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs:38:17
   |
LL |     while let b1, b2, b3 = reading_frame.next().expect("there should be a start codon") {
   |     -----       ^
   |     |
   |     while parsing the condition of this `while` expression
   |
help: try adding parentheses to match on a tuple
   |
LL |     while let (b1, b2, b3) = reading_frame.next().expect("there should be a start codon") {
   |               +          +

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs:49:14
   |
LL |     if let b1, b2, b3 = reading_frame.next().unwrap() {
   |              ^
   |
help: try adding parentheses to match on a tuple
   |
LL |     if let (b1, b2, b3) = reading_frame.next().unwrap() {
   |            +          +

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs:59:28
   |
LL |         Nucleotide::Adenine, Nucleotide::Cytosine, _ => true
   |                            ^
   |
help: try adding parentheses to match on a tuple...
   |
LL |         (Nucleotide::Adenine, Nucleotide::Cytosine, _) => true
   |         +                                            +
help: ...or a vertical bar to match on alternative
   |
LL -         Nucleotide::Adenine, Nucleotide::Cytosine, _ => true
LL +         Nucleotide::Adenine | Nucleotide::Cytosine, _ => true
   |

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs:67:10
   |
LL |     for x, _barr_body in women.iter().map(|woman| woman.allosomes.clone()) {
   |          ^
   |
help: try adding parentheses to match on a tuple
   |
LL |     for (x, _barr_body) in women.iter().map(|woman| woman.allosomes.clone()) {
   |         +             +

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs:75:10
   |
LL |     for x, y @ Allosome::Y(_) in men.iter().map(|man| man.allosomes.clone()) {
   |          ^
   |
help: try adding parentheses to match on a tuple
   |
LL |     for (x, y @ Allosome::Y(_)) in men.iter().map(|man| man.allosomes.clone()) {
   |         +                     +

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.rs:84:14
   |
LL |     let women, men: (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
   |              ^
   |
help: try adding parentheses to match on a tuple
   |
LL |     let (women, men): (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
   |         +          +

error: aborting due to 6 previous errors
------------------------------------------

---

8    |
9 LL |         (Some(_),)
10    |         +        +
- help: ...or a vertical bar to match on multiple alternatives
+ help: ...or a vertical bar to match on alternative
12    |
13 LL -         Some(_),
14 LL +         Some(_) |


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args feature-gates/feature-gate-never_patterns.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-never_patterns" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:33:16
   |
LL |         Some(_),
   |                ^
   |
help: try adding parentheses to match on a tuple...
   |
LL |         (Some(_),)
   |         +        +
help: ...or a vertical bar to match on alternative
   |
LL -         Some(_),
LL +         Some(_) |
   |

error[E0658]: `!` patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:8:24
   |
LL |     let (Ok(_x) | Err(&!)) = res.as_ref();
   |                        ^
   |
   = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information
   = help: add `#![feature(never_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: `!` patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:14:13
   |
LL |             !
   |             ^
   |
   = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information
   = help: add `#![feature(never_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: `!` patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:20:13
   |
LL |             !
   |             ^
   |
   = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information
   = help: add `#![feature(never_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: `!` patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:25:13
   |
LL |             ! => {}
   |             ^
   |
   = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information
   = help: add `#![feature(never_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: `match` arm with no body
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:38:9
   |
LL |         Some(_)
---
   |             ^
   |
   = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information
   = help: add `#![feature(never_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: `!` patterns are experimental
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:54:13
   |
LL |         Err(!) if false,
   |             ^
   |
   = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information
   = help: add `#![feature(never_patterns)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: `match` arm with no body
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:64:9
   |
LL |         Some(_)
---

error: a guard on a never pattern will never be run
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-never_patterns.rs:54:19
   |
LL |         Err(!) if false,
   |                   ^^^^^ help: remove this guard

error: aborting due to 13 previous errors

For more information about this error, try `rustc --explain E0658`.
------------------------------------------
---

16    |
17 LL |         (Some(_),)
18    |         +        +
- help: ...or a vertical bar to match on multiple alternatives
+ help: ...or a vertical bar to match on alternative
20    |
21 LL -         Some(_),
22 LL +         Some(_) |

36 LL |
37 LL ~         _) => {}
38    |
- help: ...or a vertical bar to match on multiple alternatives
+ help: ...or a vertical bar to match on alternative
40    |
- LL ~         Some(_) |
- LL +
- LL +
- LL +
- LL ~         _ => {}
+ LL -         Some(_),
+ LL +         Some(_) |
46    |
47 
48 error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args parser/match-arm-without-body.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/parser/match-arm-without-body.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/parser/match-arm-without-body" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: expected one of `=>`, `if`, or `|`, found reserved identifier `_`
##[error]  --> /checkout/tests/ui/parser/match-arm-without-body.rs:13:9
   |
LL |         Some(_)
   |                - expected one of `=>`, `if`, or `|`
LL |         _ => {}
   |         ^ unexpected token

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/parser/match-arm-without-body.rs:17:16
   |
LL |         Some(_),
   |                ^
   |
help: try adding parentheses to match on a tuple...
   |
LL |         (Some(_),)
   |         +        +
help: ...or a vertical bar to match on alternative
   |
LL -         Some(_),
LL +         Some(_) |
   |

error: unexpected `,` in pattern
##[error]  --> /checkout/tests/ui/parser/match-arm-without-body.rs:23:16
   |
LL |         Some(_),
   |                ^
   |
help: try adding parentheses to match on a tuple...
   |
LL ~         (Some(_),
LL |         //~^ ERROR unexpected `,` in pattern
LL |         //~| HELP try adding parentheses to match on a tuple
LL |         //~| HELP or a vertical bar to match on multiple alternatives
LL ~         _) => {}
   |
help: ...or a vertical bar to match on alternative
   |
LL -         Some(_),
LL +         Some(_) |
   |

error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
##[error]  --> /checkout/tests/ui/parser/match-arm-without-body.rs:36:9
   |
LL |         Some(_) if true
   |                        - expected one of `.`, `=>`, `?`, or an operator
LL |         _ => {}
   |         ^ unexpected token

error: expected `,` following `match` arm
##[error]  --> /checkout/tests/ui/parser/match-arm-without-body.rs:66:15
   |
LL |         pat!()
   |               ^
   |
@Kivooeo
Copy link
Contributor

Kivooeo commented Jul 2, 2025

This will definitely need test updates with reblessing as mentioned above - not just the parser/ but the entire tests/ui, since the CI errors are coming from various parts.

Could you clarify how this change was tested locally? It would help to understand the testing approach used, especially, given that no new tests were added and existing ones weren't updated

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
6 participants