diff options
Diffstat (limited to 'crates/hir_def/src/nameres.rs')
-rw-r--r-- | crates/hir_def/src/nameres.rs | 16 |
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)] |
55 | mod tests; | 55 | mod tests; |
56 | mod proc_macro; | ||
56 | 57 | ||
57 | use std::sync::Arc; | 58 | use std::sync::Arc; |
58 | 59 | ||
59 | use base_db::{CrateId, Edition, FileId}; | 60 | use base_db::{CrateId, Edition, FileId}; |
60 | use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; | 61 | use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile, MacroDefId}; |
61 | use la_arena::Arena; | 62 | use la_arena::Arena; |
62 | use profile::Count; | 63 | use profile::Count; |
63 | use rustc_hash::FxHashMap; | 64 | use 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 | ||
77 | use 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 | } |