aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/item_scope.rs2
-rw-r--r--crates/hir_def/src/nameres/collector.rs13
2 files changed, 8 insertions, 7 deletions
diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs
index aafd73b60..f3ebe7c72 100644
--- a/crates/hir_def/src/item_scope.rs
+++ b/crates/hir_def/src/item_scope.rs
@@ -252,7 +252,7 @@ impl ItemScope {
252 .for_each(|vis| *vis = Visibility::Module(this_module)); 252 .for_each(|vis| *vis = Visibility::Module(this_module));
253 253
254 for (mac, vis) in self.macros.values_mut() { 254 for (mac, vis) in self.macros.values_mut() {
255 if let MacroDefKind::ProcMacro(_) = mac.kind { 255 if let MacroDefKind::ProcMacro(..) = mac.kind {
256 // FIXME: Technically this is insufficient since reexports of proc macros are also 256 // FIXME: Technically this is insufficient since reexports of proc macros are also
257 // forbidden. Practically nobody does that. 257 // forbidden. Practically nobody does that.
258 continue; 258 continue;
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 45a79e896..696370ada 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -353,17 +353,17 @@ impl DefCollector<'_> {
353 /// use a dummy expander that always errors. This comes with the drawback of macros potentially 353 /// use a dummy expander that always errors. This comes with the drawback of macros potentially
354 /// going out of sync with what the build system sees (since we resolve using VFS state, but 354 /// going out of sync with what the build system sees (since we resolve using VFS state, but
355 /// Cargo builds only on-disk files). We could and probably should add diagnostics for that. 355 /// Cargo builds only on-disk files). We could and probably should add diagnostics for that.
356 fn resolve_proc_macro(&mut self, name: &Name) { 356 fn resolve_proc_macro(&mut self, name: &Name, ast_id: AstId<ast::Fn>) {
357 self.exports_proc_macros = true; 357 self.exports_proc_macros = true;
358 let macro_def = match self.proc_macros.iter().find(|(n, _)| n == name) { 358 let macro_def = match self.proc_macros.iter().find(|(n, _)| n == name) {
359 Some((_, expander)) => MacroDefId { 359 Some((_, expander)) => MacroDefId {
360 krate: self.def_map.krate, 360 krate: self.def_map.krate,
361 kind: MacroDefKind::ProcMacro(*expander), 361 kind: MacroDefKind::ProcMacro(*expander, ast_id),
362 local_inner: false, 362 local_inner: false,
363 }, 363 },
364 None => MacroDefId { 364 None => MacroDefId {
365 krate: self.def_map.krate, 365 krate: self.def_map.krate,
366 kind: MacroDefKind::ProcMacro(ProcMacroExpander::dummy(self.def_map.krate)), 366 kind: MacroDefKind::ProcMacro(ProcMacroExpander::dummy(self.def_map.krate), ast_id),
367 local_inner: false, 367 local_inner: false,
368 }, 368 },
369 }; 369 };
@@ -1116,7 +1116,8 @@ impl ModCollector<'_, '_> {
1116 ModItem::Function(id) => { 1116 ModItem::Function(id) => {
1117 let func = &self.item_tree[id]; 1117 let func = &self.item_tree[id];
1118 1118
1119 self.collect_proc_macro_def(&func.name, &attrs); 1119 let ast_id = InFile::new(self.file_id, func.ast_id);
1120 self.collect_proc_macro_def(&func.name, ast_id, &attrs);
1120 1121
1121 def = Some(DefData { 1122 def = Some(DefData {
1122 id: FunctionLoc { 1123 id: FunctionLoc {
@@ -1383,7 +1384,7 @@ impl ModCollector<'_, '_> {
1383 } 1384 }
1384 1385
1385 /// If `attrs` registers a procedural macro, collects its definition. 1386 /// If `attrs` registers a procedural macro, collects its definition.
1386 fn collect_proc_macro_def(&mut self, func_name: &Name, attrs: &Attrs) { 1387 fn collect_proc_macro_def(&mut self, func_name: &Name, ast_id: AstId<ast::Fn>, attrs: &Attrs) {
1387 // FIXME: this should only be done in the root module of `proc-macro` crates, not everywhere 1388 // FIXME: this should only be done in the root module of `proc-macro` crates, not everywhere
1388 // FIXME: distinguish the type of macro 1389 // FIXME: distinguish the type of macro
1389 let macro_name = if attrs.by_key("proc_macro").exists() 1390 let macro_name = if attrs.by_key("proc_macro").exists()
@@ -1404,7 +1405,7 @@ impl ModCollector<'_, '_> {
1404 } 1405 }
1405 }; 1406 };
1406 1407
1407 self.def_collector.resolve_proc_macro(&macro_name); 1408 self.def_collector.resolve_proc_macro(&macro_name, ast_id);
1408 } 1409 }
1409 1410
1410 fn collect_macro_rules(&mut self, id: FileItemTreeId<MacroRules>) { 1411 fn collect_macro_rules(&mut self, id: FileItemTreeId<MacroRules>) {