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:
bors[bot] 2020-12-02 14:03:57 +00:00 committed by GitHub
commit a3043cf53f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}
"#,
);
}