summaryrefslogtreecommitdiffstats
path: root/tests/ui/or-patterns/remove-leading-vert.fixed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/or-patterns/remove-leading-vert.fixed
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/or-patterns/remove-leading-vert.fixed')
-rw-r--r--tests/ui/or-patterns/remove-leading-vert.fixed48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/ui/or-patterns/remove-leading-vert.fixed b/tests/ui/or-patterns/remove-leading-vert.fixed
new file mode 100644
index 000000000..b1cd0a944
--- /dev/null
+++ b/tests/ui/or-patterns/remove-leading-vert.fixed
@@ -0,0 +1,48 @@
+// Test the suggestion to remove a leading, or trailing `|`.
+
+// run-rustfix
+
+#![allow(warnings)]
+
+fn main() {}
+
+#[cfg(FALSE)]
+fn leading() {
+ fn fun1( A: E) {} //~ ERROR top-level or-patterns are not allowed
+ fn fun2( A: E) {} //~ ERROR unexpected `||` before function parameter
+ let ( | A): E;
+ let ( | A): (E); //~ ERROR unexpected token `||` in pattern
+ let ( | A,): (E,);
+ let [ | A ]: [E; 1];
+ let [ | A ]: [E; 1]; //~ ERROR unexpected token `||` in pattern
+ let TS( | A ): TS;
+ let TS( | A ): TS; //~ ERROR unexpected token `||` in pattern
+ let NS { f: | A }: NS;
+ let NS { f: | A }: NS; //~ ERROR unexpected token `||` in pattern
+}
+
+#[cfg(FALSE)]
+fn trailing() {
+ let ( A ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let (a ,): (E,); //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let ( A | B ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let [ A | B ]: [E; 1]; //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let S { f: B }; //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let ( A | B ): E; //~ ERROR unexpected token `||` in pattern
+ //~^ ERROR a trailing `|` is not allowed in an or-pattern
+ match A {
+ A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern
+ A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern
+ A | B => {} //~ ERROR unexpected token `||` in pattern
+ //~^ ERROR a trailing `|` is not allowed in an or-pattern
+ | A | B => {}
+ //~^ ERROR a trailing `|` is not allowed in an or-pattern
+ }
+
+ // These test trailing-vert in `let` bindings, but they also test that we don't emit a
+ // duplicate suggestion that would confuse rustfix.
+
+ let a : u8 = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let a = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern
+ let a ; //~ ERROR a trailing `|` is not allowed in an or-pattern
+}