Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/nameres/attr_resolution.rs')
| -rw-r--r-- | crates/hir-def/src/nameres/attr_resolution.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/hir-def/src/nameres/attr_resolution.rs b/crates/hir-def/src/nameres/attr_resolution.rs index 2f56d608fc..fb755026c3 100644 --- a/crates/hir-def/src/nameres/attr_resolution.rs +++ b/crates/hir-def/src/nameres/attr_resolution.rs @@ -2,7 +2,7 @@ use base_db::Crate; use hir_expand::{ - MacroCallId, MacroCallKind, MacroDefId, + AttrMacroAttrIds, MacroCallId, MacroCallKind, MacroDefId, attrs::{Attr, AttrId, AttrInput}, inert_attr_macro::find_builtin_attr_idx, mod_path::{ModPath, PathKind}, @@ -28,6 +28,7 @@ pub enum ResolvedAttr { } impl DefMap { + /// This cannot be used to resolve items that allow derives. pub(crate) fn resolve_attr_macro( &self, local_def_map: &LocalDefMap, @@ -35,6 +36,7 @@ impl DefMap { original_module: LocalModuleId, ast_id: AstIdWithPath<ast::Item>, attr: &Attr, + attr_id: AttrId, ) -> Result<ResolvedAttr, UnresolvedMacro> { // NB: does not currently work for derive helpers as they aren't recorded in the `DefMap` @@ -68,6 +70,9 @@ impl DefMap { db, &ast_id, attr, + // There aren't any active attributes before this one, because attribute macros + // replace their input, and derive macros are not allowed in this function. + AttrMacroAttrIds::from_one(attr_id), self.krate, db.macro_def(def), ))) @@ -102,6 +107,7 @@ pub(super) fn attr_macro_as_call_id( db: &dyn DefDatabase, item_attr: &AstIdWithPath<ast::Item>, macro_attr: &Attr, + censored_attr_ids: AttrMacroAttrIds, krate: Crate, def: MacroDefId, ) -> MacroCallId { @@ -121,7 +127,7 @@ pub(super) fn attr_macro_as_call_id( MacroCallKind::Attr { ast_id: item_attr.ast_id, attr_args: arg.map(Arc::new), - invoc_attr_index: macro_attr.id, + censored_attr_ids, }, macro_attr.ctxt, ) |