aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-09 12:38:01 +0100
committerJonas Schievink <[email protected]>2021-04-09 12:38:01 +0100
commitc0dd36fd425416f5465abf7f12f5d3a14b35751d (patch)
tree3fc19fa9306afd69bf5702919237753c94337007 /crates/hir_def/src/nameres
parent546da15972312f62be8a64a409d39a8d96ed53a6 (diff)
Store `#[derive]` attribute ID along macro invoc
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r--crates/hir_def/src/nameres/collector.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index f431da3f2..d13d7be27 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -13,7 +13,7 @@ use hir_expand::{
13 builtin_macro::find_builtin_macro, 13 builtin_macro::find_builtin_macro,
14 name::{AsName, Name}, 14 name::{AsName, Name},
15 proc_macro::ProcMacroExpander, 15 proc_macro::ProcMacroExpander,
16 HirFileId, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, 16 AttrId, HirFileId, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
17}; 17};
18use hir_expand::{InFile, MacroCallLoc}; 18use hir_expand::{InFile, MacroCallLoc};
19use rustc_hash::{FxHashMap, FxHashSet}; 19use rustc_hash::{FxHashMap, FxHashSet};
@@ -216,7 +216,7 @@ struct MacroDirective {
216#[derive(Clone, Debug, Eq, PartialEq)] 216#[derive(Clone, Debug, Eq, PartialEq)]
217enum MacroDirectiveKind { 217enum MacroDirectiveKind {
218 FnLike { ast_id: AstIdWithPath<ast::MacroCall> }, 218 FnLike { ast_id: AstIdWithPath<ast::MacroCall> },
219 Derive { ast_id: AstIdWithPath<ast::Item> }, 219 Derive { ast_id: AstIdWithPath<ast::Item>, derive_attr: AttrId },
220} 220}
221 221
222struct DefData<'a> { 222struct DefData<'a> {
@@ -831,10 +831,14 @@ impl DefCollector<'_> {
831 Err(UnresolvedMacro) | Ok(Err(_)) => {} 831 Err(UnresolvedMacro) | Ok(Err(_)) => {}
832 } 832 }
833 } 833 }
834 MacroDirectiveKind::Derive { ast_id } => { 834 MacroDirectiveKind::Derive { ast_id, derive_attr } => {
835 match derive_macro_as_call_id(ast_id, self.db, self.def_map.krate, |path| { 835 match derive_macro_as_call_id(
836 self.resolve_derive_macro(directive.module_id, &path) 836 ast_id,
837 }) { 837 *derive_attr,
838 self.db,
839 self.def_map.krate,
840 |path| self.resolve_derive_macro(directive.module_id, &path),
841 ) {
838 Ok(call_id) => { 842 Ok(call_id) => {
839 resolved.push((directive.module_id, call_id, directive.depth)); 843 resolved.push((directive.module_id, call_id, directive.depth));
840 res = ReachedFixedPoint::No; 844 res = ReachedFixedPoint::No;
@@ -1368,7 +1372,7 @@ impl ModCollector<'_, '_> {
1368 self.def_collector.unexpanded_macros.push(MacroDirective { 1372 self.def_collector.unexpanded_macros.push(MacroDirective {
1369 module_id: self.module_id, 1373 module_id: self.module_id,
1370 depth: self.macro_depth + 1, 1374 depth: self.macro_depth + 1,
1371 kind: MacroDirectiveKind::Derive { ast_id }, 1375 kind: MacroDirectiveKind::Derive { ast_id, derive_attr: derive.id },
1372 }); 1376 });
1373 } 1377 }
1374 } 1378 }