about summary refs log tree commit diff
path: root/src/test/ui/pattern
diff options
context:
space:
mode:
authorLeSeulArtichaut <leseulartichaut@gmail.com>2020-01-02 20:13:40 +0100
committerLeSeulArtichaut <leseulartichaut@gmail.com>2020-01-02 20:16:55 +0100
commit318280519d7a721e36d9508ab185e85bde21e2f5 (patch)
tree9563795d4fe72854ddc9c56bc7186a89f12c2fe4 /src/test/ui/pattern
parentf474c0084a23207f89bd082b441bfb4701c8c2dc (diff)
downloadrust-318280519d7a721e36d9508ab185e85bde21e2f5.tar.gz
rust-318280519d7a721e36d9508ab185e85bde21e2f5.zip
Move test
Co-authored-by: Centril <twingoow@gmail.com>
Diffstat (limited to 'src/test/ui/pattern')
-rw-r--r--src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.rs33
-rw-r--r--src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr24
2 files changed, 57 insertions, 0 deletions
diff --git a/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.rs b/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.rs
new file mode 100644
index 00000000000..d106bf71341
--- /dev/null
+++ b/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.rs
@@ -0,0 +1,33 @@
+// Test for issue #67776: binding named the same as enum variant
+// should report a warning even when matching against a borrow
+
+// check-pass
+
+#![allow(unused_variables)]
+#![allow(non_snake_case)]
+
+enum Foo {
+    Bar,
+    Baz,
+}
+
+
+fn fn2(e: Foo) {
+    match e {
+        Bar => println!("A"),
+        //~^ WARNING named the same as one of the variants of the type `Foo`
+        Baz => println!("B"),
+        //~^ WARNING named the same as one of the variants of the type `Foo`
+    }
+}
+
+fn fn1(e: &Foo) {
+    match e {
+        Bar => println!("A"),
+        //~^ WARNING named the same as one of the variants of the type `Foo`
+        Baz => println!("B"),
+        //~^ WARNING named the same as one of the variants of the type `Foo`
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr b/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr
new file mode 100644
index 00000000000..cadf5e6cdee
--- /dev/null
+++ b/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr
@@ -0,0 +1,24 @@
+warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
+  --> $DIR/match-same-name-enum-variant.rs:14:9
+   |
+LL |         Bar => println!("A"),
+   |         ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
+
+warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
+  --> $DIR/match-same-name-enum-variant.rs:16:9
+   |
+LL |         Baz => println!("B"),
+   |         ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
+
+warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
+  --> $DIR/match-same-name-enum-variant.rs:23:9
+   |
+LL |         Bar => println!("A"),
+   |         ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
+
+warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
+  --> $DIR/match-same-name-enum-variant.rs:25:9
+   |
+LL |         Baz => println!("B"),
+   |         ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
+