Support macros in pattern position

This commit is contained in:
Jonas Schievink 2021-04-10 23:12:02 +02:00
parent bd675c8a8b
commit e2c1da36f5
7 changed files with 88 additions and 10 deletions

View file

@ -1185,6 +1185,32 @@ pub mod theitem {
pub fn gimme() -> theitem::TheItem {
theitem::TheItem
}
"#,
);
}
#[test]
fn goto_ident_from_pat_macro() {
check(
r#"
macro_rules! pat {
($name:ident) => { Enum::Variant1($name) }
}
enum Enum {
Variant1(u8),
Variant2,
}
fn f(e: Enum) {
match e {
pat!(bind) => {
//^^^^
bind$0
}
Enum::Variant2 => {}
}
}
"#,
);
}