aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body/lower.rs
diff options
context:
space:
mode:
authorBrandon <[email protected]>2021-03-16 07:46:57 +0000
committerBrandon <[email protected]>2021-03-16 07:52:58 +0000
commit0103f5df8fff2ccdbfb03adfe432b69c7840cf42 (patch)
tree0ec3903c77b7311ccf52306d94cc052225b43c7d /crates/hir_def/src/body/lower.rs
parentc0a2b4e826e1da20d3cfa8c279fcdffa24f32a7d (diff)
Fix missing unresolved macro diagnostic in function body
Diffstat (limited to 'crates/hir_def/src/body/lower.rs')
-rw-r--r--crates/hir_def/src/body/lower.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 8934ae6c9..08f0c32f4 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -24,7 +24,7 @@ use crate::{
24 body::{Body, BodySourceMap, Expander, LabelSource, PatPtr, SyntheticSyntax}, 24 body::{Body, BodySourceMap, Expander, LabelSource, PatPtr, SyntheticSyntax},
25 builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}, 25 builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint},
26 db::DefDatabase, 26 db::DefDatabase,
27 diagnostics::{InactiveCode, MacroError, UnresolvedProcMacro}, 27 diagnostics::{InactiveCode, MacroError, UnresolvedMacroCall, UnresolvedProcMacro},
28 expr::{ 28 expr::{
29 dummy_expr_id, ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Label, 29 dummy_expr_id, ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Label,
30 LabelId, Literal, LogicOp, MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, 30 LabelId, Literal, LogicOp, MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField,
@@ -33,7 +33,7 @@ use crate::{
33 item_scope::BuiltinShadowMode, 33 item_scope::BuiltinShadowMode,
34 path::{GenericArgs, Path}, 34 path::{GenericArgs, Path},
35 type_ref::{Mutability, Rawness, TypeRef}, 35 type_ref::{Mutability, Rawness, TypeRef},
36 AdtId, BlockLoc, ModuleDefId, 36 AdtId, BlockLoc, ModuleDefId, UnresolvedMacro,
37}; 37};
38 38
39use super::{diagnostics::BodyDiagnostic, ExprSource, PatSource}; 39use super::{diagnostics::BodyDiagnostic, ExprSource, PatSource};
@@ -542,6 +542,17 @@ impl ExprCollector<'_> {
542 let macro_call = self.expander.to_source(AstPtr::new(&e)); 542 let macro_call = self.expander.to_source(AstPtr::new(&e));
543 let res = self.expander.enter_expand(self.db, e); 543 let res = self.expander.enter_expand(self.db, e);
544 544
545 let res = match res {
546 Ok(res) => res,
547 Err(UnresolvedMacro) => {
548 self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedMacroCall(
549 UnresolvedMacroCall { file: outer_file, node: syntax_ptr.cast().unwrap() },
550 ));
551 collector(self, None);
552 return;
553 }
554 };
555
545 match &res.err { 556 match &res.err {
546 Some(ExpandError::UnresolvedProcMacro) => { 557 Some(ExpandError::UnresolvedProcMacro) => {
547 self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro( 558 self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro(