Add mbe stmt matcher

This commit is contained in:
Edwin Cheng 2019-04-17 12:34:43 +08:00
parent 546d9be2a7
commit 57e4122b89
7 changed files with 136 additions and 89 deletions

View file

@ -582,4 +582,19 @@ SOURCE_FILE@[0; 40)
);
assert_expansion(&rules, "foo! { (a, b) }", "fn foo () {let (a , b) ;}");
}
#[test]
fn test_stmt() {
let rules = create_rules(
r#"
macro_rules! foo {
($ i:stmt) => (
fn bar() { $ i; }
)
}
"#,
);
assert_expansion(&rules, "foo! { 2 }", "fn bar () {2 ;}");
assert_expansion(&rules, "foo! { let a = 0 }", "fn bar () {let a = 0 ;}");
}
}