mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-28 04:45:05 +00:00
Merge #6699
6699: Test macro diagnostics in body lowering r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
a3043cf53f
1 changed files with 41 additions and 0 deletions
|
@ -73,3 +73,44 @@ fn f() {
|
||||||
",
|
",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn macro_diag_builtin() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
fn f() {
|
||||||
|
// Test a handful of built-in (eager) macros:
|
||||||
|
|
||||||
|
include!(invalid);
|
||||||
|
//^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation
|
||||||
|
include!("does not exist");
|
||||||
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation
|
||||||
|
|
||||||
|
env!(invalid);
|
||||||
|
//^^^^^^^^^^^^^ failed to parse or resolve macro invocation
|
||||||
|
|
||||||
|
// Lazy:
|
||||||
|
|
||||||
|
format_args!();
|
||||||
|
//^^^^^^^^^^^^^^ failed to parse or resolve macro invocation
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn macro_rules_diag() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
macro_rules! m {
|
||||||
|
() => {};
|
||||||
|
}
|
||||||
|
fn f() {
|
||||||
|
m!();
|
||||||
|
|
||||||
|
m!(hi);
|
||||||
|
//^^^^^^ leftover tokens
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue