aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/nameres.rs')
-rw-r--r--crates/hir_def/src/nameres.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs
index c97be584e..0d3a0b54f 100644
--- a/crates/hir_def/src/nameres.rs
+++ b/crates/hir_def/src/nameres.rs
@@ -53,11 +53,12 @@ mod path_resolution;
53 53
54#[cfg(test)] 54#[cfg(test)]
55mod tests; 55mod tests;
56mod proc_macro;
56 57
57use std::sync::Arc; 58use std::sync::Arc;
58 59
59use base_db::{CrateId, Edition, FileId}; 60use base_db::{CrateId, Edition, FileId};
60use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; 61use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile, MacroDefId};
61use la_arena::Arena; 62use la_arena::Arena;
62use profile::Count; 63use profile::Count;
63use rustc_hash::FxHashMap; 64use rustc_hash::FxHashMap;
@@ -73,6 +74,8 @@ use crate::{
73 AstId, BlockId, BlockLoc, LocalModuleId, ModuleDefId, ModuleId, 74 AstId, BlockId, BlockLoc, LocalModuleId, ModuleDefId, ModuleId,
74}; 75};
75 76
77use self::proc_macro::ProcMacroDef;
78
76/// Contains the results of (early) name resolution. 79/// Contains the results of (early) name resolution.
77/// 80///
78/// A `DefMap` stores the module tree and the definitions that are in scope in every module after 81/// A `DefMap` stores the module tree and the definitions that are in scope in every module after
@@ -95,6 +98,12 @@ pub struct DefMap {
95 prelude: Option<ModuleId>, 98 prelude: Option<ModuleId>,
96 extern_prelude: FxHashMap<Name, ModuleDefId>, 99 extern_prelude: FxHashMap<Name, ModuleDefId>,
97 100
101 /// Side table with additional proc. macro info, for use by name resolution in downstream
102 /// crates.
103 ///
104 /// (the primary purpose is to resolve derive helpers)
105 exported_proc_macros: FxHashMap<MacroDefId, ProcMacroDef>,
106
98 edition: Edition, 107 edition: Edition,
99 diagnostics: Vec<DefDiagnostic>, 108 diagnostics: Vec<DefDiagnostic>,
100} 109}
@@ -237,6 +246,7 @@ impl DefMap {
237 krate, 246 krate,
238 edition, 247 edition,
239 extern_prelude: FxHashMap::default(), 248 extern_prelude: FxHashMap::default(),
249 exported_proc_macros: FxHashMap::default(),
240 prelude: None, 250 prelude: None,
241 root, 251 root,
242 modules, 252 modules,
@@ -565,7 +575,7 @@ mod diagnostics {
565 let node = ast.to_node(db.upcast()); 575 let node = ast.to_node(db.upcast());
566 (ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)), None) 576 (ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)), None)
567 } 577 }
568 MacroCallKind::Attr(ast, name) => { 578 MacroCallKind::Derive(ast, name) => {
569 let node = ast.to_node(db.upcast()); 579 let node = ast.to_node(db.upcast());
570 580
571 // Compute the precise location of the macro name's token in the derive 581 // Compute the precise location of the macro name's token in the derive
@@ -621,7 +631,7 @@ mod diagnostics {
621 let node = ast.to_node(db.upcast()); 631 let node = ast.to_node(db.upcast());
622 (ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) 632 (ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
623 } 633 }
624 MacroCallKind::Attr(ast, _) => { 634 MacroCallKind::Derive(ast, _) => {
625 let node = ast.to_node(db.upcast()); 635 let node = ast.to_node(db.upcast());
626 (ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node))) 636 (ast.file_id, SyntaxNodePtr::from(AstPtr::new(&node)))
627 } 637 }