diff options
Diffstat (limited to 'crates/hir_def/src/body/lower.rs')
-rw-r--r-- | crates/hir_def/src/body/lower.rs | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 2a7e0205f..da1fdac33 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -8,7 +8,7 @@ use hir_expand::{ | |||
8 | ast_id_map::{AstIdMap, FileAstId}, | 8 | ast_id_map::{AstIdMap, FileAstId}, |
9 | hygiene::Hygiene, | 9 | hygiene::Hygiene, |
10 | name::{name, AsName, Name}, | 10 | name::{name, AsName, Name}, |
11 | ExpandError, HirFileId, | 11 | ExpandError, HirFileId, InFile, |
12 | }; | 12 | }; |
13 | use la_arena::Arena; | 13 | use la_arena::Arena; |
14 | use profile::Count; | 14 | use profile::Count; |
@@ -23,9 +23,9 @@ use syntax::{ | |||
23 | use crate::{ | 23 | use crate::{ |
24 | adt::StructKind, | 24 | adt::StructKind, |
25 | body::{Body, BodySourceMap, Expander, LabelSource, PatPtr, SyntheticSyntax}, | 25 | body::{Body, BodySourceMap, Expander, LabelSource, PatPtr, SyntheticSyntax}, |
26 | body::{BodyDiagnostic, ExprSource, PatSource}, | ||
26 | builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}, | 27 | builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}, |
27 | db::DefDatabase, | 28 | db::DefDatabase, |
28 | diagnostics::{InactiveCode, MacroError, UnresolvedMacroCall, UnresolvedProcMacro}, | ||
29 | expr::{ | 29 | expr::{ |
30 | dummy_expr_id, ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Label, | 30 | dummy_expr_id, ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Label, |
31 | LabelId, Literal, LogicOp, MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, | 31 | LabelId, Literal, LogicOp, MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, |
@@ -38,8 +38,6 @@ use crate::{ | |||
38 | AdtId, BlockLoc, ModuleDefId, UnresolvedMacro, | 38 | AdtId, BlockLoc, ModuleDefId, UnresolvedMacro, |
39 | }; | 39 | }; |
40 | 40 | ||
41 | use super::{diagnostics::BodyDiagnostic, ExprSource, PatSource}; | ||
42 | |||
43 | pub struct LowerCtx<'a> { | 41 | pub struct LowerCtx<'a> { |
44 | pub db: &'a dyn DefDatabase, | 42 | pub db: &'a dyn DefDatabase, |
45 | hygiene: Hygiene, | 43 | hygiene: Hygiene, |
@@ -592,13 +590,10 @@ impl ExprCollector<'_> { | |||
592 | let res = match res { | 590 | let res = match res { |
593 | Ok(res) => res, | 591 | Ok(res) => res, |
594 | Err(UnresolvedMacro { path }) => { | 592 | Err(UnresolvedMacro { path }) => { |
595 | self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedMacroCall( | 593 | self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedMacroCall { |
596 | UnresolvedMacroCall { | 594 | node: InFile::new(outer_file, syntax_ptr), |
597 | file: outer_file, | 595 | path, |
598 | node: syntax_ptr.cast().unwrap(), | 596 | }); |
599 | path, | ||
600 | }, | ||
601 | )); | ||
602 | collector(self, None); | 597 | collector(self, None); |
603 | return; | 598 | return; |
604 | } | 599 | } |
@@ -606,21 +601,15 @@ impl ExprCollector<'_> { | |||
606 | 601 | ||
607 | match &res.err { | 602 | match &res.err { |
608 | Some(ExpandError::UnresolvedProcMacro) => { | 603 | Some(ExpandError::UnresolvedProcMacro) => { |
609 | self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro( | 604 | self.source_map.diagnostics.push(BodyDiagnostic::UnresolvedProcMacro { |
610 | UnresolvedProcMacro { | 605 | node: InFile::new(outer_file, syntax_ptr), |
611 | file: outer_file, | 606 | }); |
612 | node: syntax_ptr.into(), | ||
613 | precise_location: None, | ||
614 | macro_name: None, | ||
615 | }, | ||
616 | )); | ||
617 | } | 607 | } |
618 | Some(err) => { | 608 | Some(err) => { |
619 | self.source_map.diagnostics.push(BodyDiagnostic::MacroError(MacroError { | 609 | self.source_map.diagnostics.push(BodyDiagnostic::MacroError { |
620 | file: outer_file, | 610 | node: InFile::new(outer_file, syntax_ptr), |
621 | node: syntax_ptr.into(), | ||
622 | message: err.to_string(), | 611 | message: err.to_string(), |
623 | })); | 612 | }); |
624 | } | 613 | } |
625 | None => {} | 614 | None => {} |
626 | } | 615 | } |
@@ -945,12 +934,14 @@ impl ExprCollector<'_> { | |||
945 | return Some(()); | 934 | return Some(()); |
946 | } | 935 | } |
947 | 936 | ||
948 | self.source_map.diagnostics.push(BodyDiagnostic::InactiveCode(InactiveCode { | 937 | self.source_map.diagnostics.push(BodyDiagnostic::InactiveCode { |
949 | file: self.expander.current_file_id, | 938 | node: InFile::new( |
950 | node: SyntaxNodePtr::new(owner.syntax()), | 939 | self.expander.current_file_id, |
940 | SyntaxNodePtr::new(owner.syntax()), | ||
941 | ), | ||
951 | cfg, | 942 | cfg, |
952 | opts: self.expander.cfg_options().clone(), | 943 | opts: self.expander.cfg_options().clone(), |
953 | })); | 944 | }); |
954 | 945 | ||
955 | None | 946 | None |
956 | } | 947 | } |