Skip to content

Commit f474c00

Browse files
Added test
1 parent 4f63985 commit f474c00

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Test for issue #67776: binding named the same as enum variant
2+
// should report a warning even when matching against a borrow
3+
4+
// check-pass
5+
6+
#![allow(unused_variables)]
7+
#![allow(non_snake_case)]
8+
9+
enum Foo {
10+
Bar,
11+
Baz,
12+
}
13+
14+
15+
fn fn2(e: Foo) {
16+
match e {
17+
Bar => println!("A"),
18+
//~^ WARNING named the same as one of the variants of the type `Foo`
19+
Baz => println!("B"),
20+
//~^ WARNING named the same as one of the variants of the type `Foo`
21+
}
22+
}
23+
24+
fn fn1(e: &Foo) {
25+
match e {
26+
Bar => println!("A"),
27+
//~^ WARNING named the same as one of the variants of the type `Foo`
28+
Baz => println!("B"),
29+
//~^ WARNING named the same as one of the variants of the type `Foo`
30+
}
31+
}
32+
33+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
2+
--> $DIR/match-same-name-enum-variant.rs:14:9
3+
|
4+
LL | Bar => println!("A"),
5+
| ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
6+
7+
warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
8+
--> $DIR/match-same-name-enum-variant.rs:16:9
9+
|
10+
LL | Baz => println!("B"),
11+
| ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
12+
13+
warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
14+
--> $DIR/match-same-name-enum-variant.rs:23:9
15+
|
16+
LL | Bar => println!("A"),
17+
| ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
18+
19+
warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
20+
--> $DIR/match-same-name-enum-variant.rs:25:9
21+
|
22+
LL | Baz => println!("B"),
23+
| ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
24+

0 commit comments

Comments
 (0)