8072: Fix "unset `OUT_DIR`" diagnostic when using it in item position r=jonas-schievink a=jonas-schievink

"load out dirs from check" is enabled by default now, but better late than never I guess.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2021-03-17 20:42:52 +00:00 committed by GitHub
commit 9d691530d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -1469,7 +1469,9 @@ impl ModCollector<'_, '_> {
)
})
},
&mut |err| error = Some(err),
&mut |err| {
error.get_or_insert(err);
},
) {
Ok(Ok(macro_call_id)) => {
self.def_collector.unexpanded_macros.push(MacroDirective {

View File

@ -200,3 +200,20 @@ fn builtin_macro_fails_expansion() {
"#,
);
}
#[test]
fn good_out_dir_diagnostic() {
check_diagnostics(
r#"
#[rustc_builtin_macro]
macro_rules! include { () => {} }
#[rustc_builtin_macro]
macro_rules! env { () => {} }
#[rustc_builtin_macro]
macro_rules! concat { () => {} }
include!(concat!(env!("OUT_DIR"), "/out.rs"));
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix
"#,
);
}