From 0103f5df8fff2ccdbfb03adfe432b69c7840cf42 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 16 Mar 2021 00:46:57 -0700 Subject: Fix missing unresolved macro diagnostic in function body --- crates/hir_def/src/body/lower.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'crates/hir_def/src/body/lower.rs') 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::{ body::{Body, BodySourceMap, Expander, LabelSource, PatPtr, SyntheticSyntax}, builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}, db::DefDatabase, - diagnostics::{InactiveCode, MacroError, UnresolvedProcMacro}, + diagnostics::{InactiveCode, MacroError, UnresolvedMacroCall, UnresolvedProcMacro}, expr::{ dummy_expr_id, ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Label, LabelId, Literal, LogicOp, MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, @@ -33,7 +33,7 @@ use crate::{ item_scope::BuiltinShadowMode, path::{GenericArgs, Path}, type_ref::{Mutability, Rawness, TypeRef}, - AdtId, BlockLoc, ModuleDefId, + AdtId, BlockLoc, ModuleDefId, UnresolvedMacro, }; use super::{diagnostics::BodyDiagnostic, ExprSource, PatSource}; @@ -542,6 +542,17 @@ impl ExprCollector<'_> { let macro_call = self.expander.to_source(AstPtr::new(&e)); let res = self.expander.enter_expand(self.db, e); + let res = match res { + Ok(res) => res, + Err(UnresolvedMacro) => { + self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedMacroCall( + UnresolvedMacroCall { file: outer_file, node: syntax_ptr.cast().unwrap() }, + )); + collector(self, None); + return; + } + }; + match &res.err { Some(ExpandError::UnresolvedProcMacro) => { self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro( -- cgit v1.2.3