Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe.rs | 28 | ||||
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe/matching.rs | 49 |
2 files changed, 49 insertions, 28 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs index 4bef508840..466c85fc5b 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -300,34 +300,6 @@ fn baz() { } #[test] -fn asi() { - // Thanks, Christopher! - // - // https://internals.rust-lang.org/t/understanding-decisions-behind-semicolons/15181/29 - check( - r#" -macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); } - -fn main() { - asi! { - let a = 2 - let b = 5 - drop(b-a) - println!("{}", a+b) - } -} -"#, - expect![[r#" -macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); } - -fn main() { - let a = 2let b = 5drop(b-a)println!("{}", a+b) -} -"#]], - ) -} - -#[test] fn test_match_group_empty_fixed_token() { check( r#" diff --git a/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs index 9fb6d96b72..83e8937f5b 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs @@ -50,3 +50,52 @@ macro_rules! m{ ($fmt:expr) => (); } "#]], ); } + +#[test] +fn asi() { + // Thanks, Christopher! + // + // https://internals.rust-lang.org/t/understanding-decisions-behind-semicolons/15181/29 + check( + r#" +macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); } + +fn main() { + asi! { + let a = 2 + let b = 5 + drop(b-a) + println!("{}", a+b) + } +} +"#, + expect![[r#" +macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); } + +fn main() { + let a = 2let b = 5drop(b-a)println!("{}", a+b) +} +"#]], + ) +} + +#[test] +fn stmt_boundaries() { + // FIXME: this actually works OK under rustc. + check( + r#" +macro_rules! m { + ($($s:stmt)*) => (stringify!($($s |)*)) +} +// +errors +m!(;;92;let x = 92; loop {};); +"#, + expect![[r#" +macro_rules! m { + ($($s:stmt)*) => (stringify!($($s |)*)) +} +/* error: expected Stmt *//* parse error: expected SEMICOLON */ +stringify!() +"#]], + ); +} |