From 5a8f963426c72c5bd306b2620a6c148b720217d0 Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Thu, 2 Oct 2025 20:13:18 +0200 Subject: fix wording; we're replacing coma with a bar --- .../only-replace-intended-bar-not-all-in-pattern.fixed | 18 ------------------ .../only-replace-intended-bar-not-all-in-pattern.rs | 18 ------------------ ...only-replace-intended-bar-not-all-in-pattern.stderr | 18 ------------------ ...only-replace-intended-coma-not-all-in-pattern.fixed | 18 ++++++++++++++++++ .../only-replace-intended-coma-not-all-in-pattern.rs | 18 ++++++++++++++++++ ...nly-replace-intended-coma-not-all-in-pattern.stderr | 18 ++++++++++++++++++ 6 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.fixed delete mode 100644 tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.rs delete mode 100644 tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.stderr create mode 100644 tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.fixed create mode 100644 tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.rs create mode 100644 tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.stderr diff --git a/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.fixed b/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.fixed deleted file mode 100644 index 5abc1edd381..00000000000 --- a/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.fixed +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-rustfix - -// Regression test for issue #143330. -// Ensure we suggest to replace only the intended bar with a comma, not all bars in the pattern. - -fn main() { - struct Foo { x: i32, ch: char } - let pos = Foo { x: 2, ch: 'x' }; - match pos { - // All commas here were replaced with bars. - // Foo { x: 2 | ch: ' |' } | Foo { x: 3 | ch: '@' } => (), - (Foo { x: 2, ch: ',' } | Foo { x: 3, ch: '@' }) => (), - //~^ ERROR unexpected `,` in pattern - //~| HELP try adding parentheses to match on a tuple... - //~| HELP ...or a vertical bar to match on alternative - _ => todo!(), - } -} diff --git a/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.rs b/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.rs deleted file mode 100644 index 5bd267c3bc4..00000000000 --- a/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-rustfix - -// Regression test for issue #143330. -// Ensure we suggest to replace only the intended bar with a comma, not all bars in the pattern. - -fn main() { - struct Foo { x: i32, ch: char } - let pos = Foo { x: 2, ch: 'x' }; - match pos { - // All commas here were replaced with bars. - // Foo { x: 2 | ch: ' |' } | Foo { x: 3 | ch: '@' } => (), - Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (), - //~^ ERROR unexpected `,` in pattern - //~| HELP try adding parentheses to match on a tuple... - //~| HELP ...or a vertical bar to match on alternative - _ => todo!(), - } -} diff --git a/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.stderr b/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.stderr deleted file mode 100644 index db0bb8c50e8..00000000000 --- a/tests/ui/suggestions/only-replace-intended-bar-not-all-in-pattern.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: unexpected `,` in pattern - --> $DIR/only-replace-intended-bar-not-all-in-pattern.rs:12:30 - | -LL | Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (), - | ^ - | -help: try adding parentheses to match on a tuple... - | -LL | (Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' }) => (), - | + + -help: ...or a vertical bar to match on alternative - | -LL - Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (), -LL + Foo { x: 2, ch: ',' } | Foo { x: 3, ch: '@' } => (), - | - -error: aborting due to 1 previous error - diff --git a/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.fixed b/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.fixed new file mode 100644 index 00000000000..0258f868f00 --- /dev/null +++ b/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.fixed @@ -0,0 +1,18 @@ +//@ run-rustfix + +// Regression test for issue #143330. +// Ensure we suggest to replace only the intended coma with a bar, not all commas in the pattern. + +fn main() { + struct Foo { x: i32, ch: char } + let pos = Foo { x: 2, ch: 'x' }; + match pos { + // All commas here were replaced with bars. + // Foo { x: 2 | ch: ' |' } | Foo { x: 3 | ch: '@' } => (), + (Foo { x: 2, ch: ',' } | Foo { x: 3, ch: '@' }) => (), + //~^ ERROR unexpected `,` in pattern + //~| HELP try adding parentheses to match on a tuple... + //~| HELP ...or a vertical bar to match on alternative + _ => todo!(), + } +} diff --git a/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.rs b/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.rs new file mode 100644 index 00000000000..7d5087fa0ff --- /dev/null +++ b/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.rs @@ -0,0 +1,18 @@ +//@ run-rustfix + +// Regression test for issue #143330. +// Ensure we suggest to replace only the intended coma with a bar, not all commas in the pattern. + +fn main() { + struct Foo { x: i32, ch: char } + let pos = Foo { x: 2, ch: 'x' }; + match pos { + // All commas here were replaced with bars. + // Foo { x: 2 | ch: ' |' } | Foo { x: 3 | ch: '@' } => (), + Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (), + //~^ ERROR unexpected `,` in pattern + //~| HELP try adding parentheses to match on a tuple... + //~| HELP ...or a vertical bar to match on alternative + _ => todo!(), + } +} diff --git a/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.stderr b/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.stderr new file mode 100644 index 00000000000..050f1b8a2b3 --- /dev/null +++ b/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.stderr @@ -0,0 +1,18 @@ +error: unexpected `,` in pattern + --> $DIR/only-replace-intended-coma-not-all-in-pattern.rs:12:30 + | +LL | Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (), + | ^ + | +help: try adding parentheses to match on a tuple... + | +LL | (Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' }) => (), + | + + +help: ...or a vertical bar to match on alternative + | +LL - Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (), +LL + Foo { x: 2, ch: ',' } | Foo { x: 3, ch: '@' } => (), + | + +error: aborting due to 1 previous error + -- cgit 1.4.1-3-g733a5