Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/macro_expansion_tests/mbe/matching.rs')
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe/matching.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs new file mode 100644 index 0000000000..cfba58c55a --- /dev/null +++ b/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs @@ -0,0 +1,41 @@ +use expect_test::expect; + +use crate::macro_expansion_tests::check; + +#[test] +fn unary_minus_is_a_literal() { + check( + r#" +macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); } +m!(92); +m!(-92); +m!(-9.2); +m!(--92); +"#, + expect![[r#" +macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); } +literal!() +literal!() +literal!() +/* error: leftover tokens */not_a_literal!() +"#]], + ) +} + +#[test] +fn wrong_nesting_level() { + check( + r#" +macro_rules! m { + ($($i:ident);*) => ($i) +} +m!{a} +"#, + expect![[r#" +macro_rules! m { + ($($i:ident);*) => ($i) +} +/* error: expected simple binding, found nested binding `i` */ +"#]], + ); +} |