Skip to content

Commit a3043cf

Browse files
Merge #6699
6699: Test macro diagnostics in body lowering r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 3e1fb11 + f4866bb commit a3043cf

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

crates/hir_def/src/body/tests.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,44 @@ fn f() {
7373
",
7474
);
7575
}
76+
77+
#[test]
78+
fn macro_diag_builtin() {
79+
check_diagnostics(
80+
r#"
81+
fn f() {
82+
// Test a handful of built-in (eager) macros:
83+
84+
include!(invalid);
85+
//^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation
86+
include!("does not exist");
87+
//^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to parse or resolve macro invocation
88+
89+
env!(invalid);
90+
//^^^^^^^^^^^^^ failed to parse or resolve macro invocation
91+
92+
// Lazy:
93+
94+
format_args!();
95+
//^^^^^^^^^^^^^^ failed to parse or resolve macro invocation
96+
}
97+
"#,
98+
);
99+
}
100+
101+
#[test]
102+
fn macro_rules_diag() {
103+
check_diagnostics(
104+
r#"
105+
macro_rules! m {
106+
() => {};
107+
}
108+
fn f() {
109+
m!();
110+
111+
m!(hi);
112+
//^^^^^^ leftover tokens
113+
}
114+
"#,
115+
);
116+
}

0 commit comments

Comments
 (0)