-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f63985
commit f474c00
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` | ||
|