use structured suggestion for pattern-named-the-same-as-variant warning
This commit is contained in:
parent
3874676dc6
commit
4650361fb6
5 changed files with 53 additions and 16 deletions
40
src/test/ui/issue-19100.fixed
Normal file
40
src/test/ui/issue-19100.fixed
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// run-rustfix
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
enum Foo {
|
||||
Bar,
|
||||
Baz
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn foo(&self) {
|
||||
match self {
|
||||
&
|
||||
Foo::Bar if true
|
||||
//~^ WARN pattern binding `Bar` is named the same as one of the variants of the type `Foo`
|
||||
=> println!("bar"),
|
||||
&
|
||||
Foo::Baz if false
|
||||
//~^ WARN pattern binding `Baz` is named the same as one of the variants of the type `Foo`
|
||||
=> println!("baz"),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// run-pass
|
||||
// run-rustfix
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
|
||||
--> $DIR/issue-19100.rs:27:1
|
||||
--> $DIR/issue-19100.rs:28:1
|
||||
|
|
||||
LL | Bar if true
|
||||
| ^^^
|
||||
|
|
||||
= help: if you meant to match on a variant, consider making the path in the pattern qualified: `Foo::Bar`
|
||||
| ^^^ 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/issue-19100.rs:31:1
|
||||
--> $DIR/issue-19100.rs:32:1
|
||||
|
|
||||
LL | Baz if false
|
||||
| ^^^
|
||||
|
|
||||
= help: if you meant to match on a variant, consider making the path in the pattern qualified: `Foo::Baz`
|
||||
| ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ warning[E0170]: pattern binding `Nil` is named the same as one of the variants o
|
|||
--> $DIR/issue-30302.rs:23:9
|
||||
|
|
||||
LL | Nil => true,
|
||||
| ^^^
|
||||
|
|
||||
= help: if you meant to match on a variant, consider making the path in the pattern qualified: `Stack::Nil`
|
||||
| ^^^ help: to match on the variant, qualify the path: `Stack::Nil`
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/issue-30302.rs:25:9
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue