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