mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Add test related to the ICE
This test doesn't reproduce the ICE since it only happens, when the macro is defined in another file. Currently we can't add tests with multiple files AFAIK Also using the auxiliary folder didn't help
This commit is contained in:
parent
87ae6c8bc9
commit
0ce564a7e1
2 changed files with 41 additions and 2 deletions
|
@ -150,4 +150,29 @@ fn match_as_ref() {
|
|||
};
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
macro_rules! foo_variant(
|
||||
($idx:expr) => (Foo::get($idx).unwrap())
|
||||
);
|
||||
|
||||
enum Foo {
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn get(idx: u8) -> Option<&'static Self> {
|
||||
match idx {
|
||||
0 => Some(&Foo::A),
|
||||
1 => Some(&Foo::B),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// ICE #3719
|
||||
match foo_variant!(0) {
|
||||
&Foo::A => println!("A"),
|
||||
_ => println!("Wild"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -278,5 +278,19 @@ LL | | Some(ref mut v) => Some(v),
|
|||
LL | | };
|
||||
| |_____^ help: try this: `mut_owned.as_mut()`
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
error: you don't need to add `&` to all patterns
|
||||
--> $DIR/matches.rs:174:5
|
||||
|
|
||||
LL | / match foo_variant!(0) {
|
||||
LL | | &Foo::A => println!("A"),
|
||||
LL | | _ => println!("Wild"),
|
||||
LL | | }
|
||||
| |_____^
|
||||
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
||||
|
|
||||
LL | match *foo_variant!(0) {
|
||||
LL | Foo::A => println!("A"),
|
||||
|
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue