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:
flip1995 2019-02-16 19:37:58 +01:00
parent 87ae6c8bc9
commit 0ce564a7e1
No known key found for this signature in database
GPG key ID: 693086869D506637
2 changed files with 41 additions and 2 deletions

View file

@ -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"),
}
}

View file

@ -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