Skip to content

Commit 841cd30

Browse files
committed
Add test
1 parent f5cfc05 commit 841cd30

File tree

2 files changed

+49
-28
lines changed

2 files changed

+49
-28
lines changed

crates/hir_def/src/macro_expansion_tests/mbe.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -299,34 +299,6 @@ fn baz() {
299299
)
300300
}
301301

302-
#[test]
303-
fn asi() {
304-
// Thanks, Christopher!
305-
//
306-
// https://internals.rust-lang.org/t/understanding-decisions-behind-semicolons/15181/29
307-
check(
308-
r#"
309-
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
310-
311-
fn main() {
312-
asi! {
313-
let a = 2
314-
let b = 5
315-
drop(b-a)
316-
println!("{}", a+b)
317-
}
318-
}
319-
"#,
320-
expect![[r#"
321-
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
322-
323-
fn main() {
324-
let a = 2let b = 5drop(b-a)println!("{}", a+b)
325-
}
326-
"#]],
327-
)
328-
}
329-
330302
#[test]
331303
fn test_match_group_empty_fixed_token() {
332304
check(

crates/hir_def/src/macro_expansion_tests/mbe/matching.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,52 @@ macro_rules! m{ ($fmt:expr) => (); }
5050
"#]],
5151
);
5252
}
53+
54+
#[test]
55+
fn asi() {
56+
// Thanks, Christopher!
57+
//
58+
// https://internals.rust-lang.org/t/understanding-decisions-behind-semicolons/15181/29
59+
check(
60+
r#"
61+
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
62+
63+
fn main() {
64+
asi! {
65+
let a = 2
66+
let b = 5
67+
drop(b-a)
68+
println!("{}", a+b)
69+
}
70+
}
71+
"#,
72+
expect![[r#"
73+
macro_rules! asi { ($($stmt:stmt)*) => ($($stmt)*); }
74+
75+
fn main() {
76+
let a = 2let b = 5drop(b-a)println!("{}", a+b)
77+
}
78+
"#]],
79+
)
80+
}
81+
82+
#[test]
83+
fn stmt_boundaries() {
84+
// FIXME: this actually works OK under rustc.
85+
check(
86+
r#"
87+
macro_rules! m {
88+
($($s:stmt)*) => (stringify!($($s |)*))
89+
}
90+
// +errors
91+
m!(;;92;let x = 92; loop {};);
92+
"#,
93+
expect![[r#"
94+
macro_rules! m {
95+
($($s:stmt)*) => (stringify!($($s |)*))
96+
}
97+
/* error: expected Stmt *//* parse error: expected SEMICOLON */
98+
stringify!()
99+
"#]],
100+
);
101+
}

0 commit comments

Comments
 (0)