diff options
Diffstat (limited to 'crates/hir_def/src/body.rs')
-rw-r--r-- | crates/hir_def/src/body.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index b9ecf22fa..41abd8f83 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -46,7 +46,7 @@ pub(crate) struct CfgExpander { | |||
46 | 46 | ||
47 | pub(crate) struct Expander { | 47 | pub(crate) struct Expander { |
48 | cfg_expander: CfgExpander, | 48 | cfg_expander: CfgExpander, |
49 | crate_def_map: Arc<DefMap>, | 49 | def_map: Arc<DefMap>, |
50 | current_file_id: HirFileId, | 50 | current_file_id: HirFileId, |
51 | ast_id_map: Arc<AstIdMap>, | 51 | ast_id_map: Arc<AstIdMap>, |
52 | module: ModuleId, | 52 | module: ModuleId, |
@@ -91,7 +91,7 @@ impl Expander { | |||
91 | let ast_id_map = db.ast_id_map(current_file_id); | 91 | let ast_id_map = db.ast_id_map(current_file_id); |
92 | Expander { | 92 | Expander { |
93 | cfg_expander, | 93 | cfg_expander, |
94 | crate_def_map, | 94 | def_map: crate_def_map, |
95 | current_file_id, | 95 | current_file_id, |
96 | ast_id_map, | 96 | ast_id_map, |
97 | module, | 97 | module, |
@@ -102,7 +102,6 @@ impl Expander { | |||
102 | pub(crate) fn enter_expand<T: ast::AstNode>( | 102 | pub(crate) fn enter_expand<T: ast::AstNode>( |
103 | &mut self, | 103 | &mut self, |
104 | db: &dyn DefDatabase, | 104 | db: &dyn DefDatabase, |
105 | local_scope: Option<&ItemScope>, | ||
106 | macro_call: ast::MacroCall, | 105 | macro_call: ast::MacroCall, |
107 | ) -> ExpandResult<Option<(Mark, T)>> { | 106 | ) -> ExpandResult<Option<(Mark, T)>> { |
108 | if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { | 107 | if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { |
@@ -112,18 +111,12 @@ impl Expander { | |||
112 | 111 | ||
113 | let macro_call = InFile::new(self.current_file_id, ¯o_call); | 112 | let macro_call = InFile::new(self.current_file_id, ¯o_call); |
114 | 113 | ||
115 | let resolver = |path: ModPath| -> Option<MacroDefId> { | 114 | let resolver = |
116 | if let Some(local_scope) = local_scope { | 115 | |path: ModPath| -> Option<MacroDefId> { self.resolve_path_as_macro(db, &path) }; |
117 | if let Some(def) = path.as_ident().and_then(|n| local_scope.get_legacy_macro(n)) { | ||
118 | return Some(def); | ||
119 | } | ||
120 | } | ||
121 | self.resolve_path_as_macro(db, &path) | ||
122 | }; | ||
123 | 116 | ||
124 | let mut err = None; | 117 | let mut err = None; |
125 | let call_id = | 118 | let call_id = |
126 | macro_call.as_call_id_with_errors(db, self.crate_def_map.krate(), resolver, &mut |e| { | 119 | macro_call.as_call_id_with_errors(db, self.def_map.krate(), resolver, &mut |e| { |
127 | err.get_or_insert(e); | 120 | err.get_or_insert(e); |
128 | }); | 121 | }); |
129 | let call_id = match call_id { | 122 | let call_id = match call_id { |
@@ -204,7 +197,7 @@ impl Expander { | |||
204 | } | 197 | } |
205 | 198 | ||
206 | fn resolve_path_as_macro(&self, db: &dyn DefDatabase, path: &ModPath) -> Option<MacroDefId> { | 199 | fn resolve_path_as_macro(&self, db: &dyn DefDatabase, path: &ModPath) -> Option<MacroDefId> { |
207 | self.crate_def_map | 200 | self.def_map |
208 | .resolve_path(db, self.module.local_id, path, BuiltinShadowMode::Other) | 201 | .resolve_path(db, self.module.local_id, path, BuiltinShadowMode::Other) |
209 | .0 | 202 | .0 |
210 | .take_macros() | 203 | .take_macros() |