aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-03-17 20:40:36 +0000
committerJonas Schievink <[email protected]>2021-03-17 20:41:32 +0000
commitc64adfe706183ccce9764853ee9c7231c57c16ab (patch)
treeaf759a4222a13c4b07823e61bc16dedfb93b3a97 /crates/hir_def
parentbba474bb52e75baf4cabb3fc73f2a4c818816857 (diff)
Use first early expansion error during nameres
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/nameres/collector.rs4
-rw-r--r--crates/hir_def/src/nameres/tests/diagnostics.rs17
2 files changed, 20 insertions, 1 deletions
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<'_, '_> {
1469 ) 1469 )
1470 }) 1470 })
1471 }, 1471 },
1472 &mut |err| error = Some(err), 1472 &mut |err| {
1473 error.get_or_insert(err);
1474 },
1473 ) { 1475 ) {
1474 Ok(Ok(macro_call_id)) => { 1476 Ok(Ok(macro_call_id)) => {
1475 self.def_collector.unexpanded_macros.push(MacroDirective { 1477 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() {
200 "#, 200 "#,
201 ); 201 );
202} 202}
203
204#[test]
205fn good_out_dir_diagnostic() {
206 check_diagnostics(
207 r#"
208 #[rustc_builtin_macro]
209 macro_rules! include { () => {} }
210 #[rustc_builtin_macro]
211 macro_rules! env { () => {} }
212 #[rustc_builtin_macro]
213 macro_rules! concat { () => {} }
214
215 include!(concat!(env!("OUT_DIR"), "/out.rs"));
216 //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix
217 "#,
218 );
219}