mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add test
This commit is contained in:
parent
f5cfc0504e
commit
841cd30b45
2 changed files with 49 additions and 28 deletions
|
@ -299,34 +299,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]
|
#[test]
|
||||||
fn test_match_group_empty_fixed_token() {
|
fn test_match_group_empty_fixed_token() {
|
||||||
check(
|
check(
|
||||||
|
|
|
@ -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!()
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue