From c64adfe706183ccce9764853ee9c7231c57c16ab Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 17 Mar 2021 21:40:36 +0100 Subject: Use first early expansion error during nameres --- crates/hir_def/src/nameres/collector.rs | 4 +++- crates/hir_def/src/nameres/tests/diagnostics.rs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 81cf652b0..d73f895b7 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -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 { diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index c22ef46fd..6becd9ff1 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs @@ -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 + "#, + ); +} -- cgit v1.2.3