Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/semantics/source_to_def.rs')
| -rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index fbce53eb16..f9c6564d01 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs @@ -87,6 +87,7 @@ use base_db::FileId; use hir_def::{ + attr::AttrId, child_by_source::ChildBySource, dyn_map::DynMap, expr::{LabelId, PatId}, @@ -210,19 +211,6 @@ impl SourceToDefCtx<'_, '_> { ast::Adt::Union(it) => self.union_to_def(InFile::new(file_id, it)).map(AdtId::UnionId), } } - pub(super) fn attr_to_def( - &mut self, - InFile { file_id, value }: InFile<ast::Attr>, - ) -> Option<crate::Attr> { - // FIXME: Use dynmap? - let adt = value.syntax().parent().and_then(ast::Adt::cast)?; - let attr_pos = ast::HasAttrs::attrs(&adt).position(|it| it == value)?; - let attrs = { - let def = self.adt_to_def(InFile::new(file_id, adt))?; - self.db.attrs(def.into()) - }; - attrs.get(attr_pos).cloned() - } pub(super) fn bind_pat_to_def( &mut self, src: InFile<ast::IdentPat>, @@ -254,16 +242,16 @@ impl SourceToDefCtx<'_, '_> { pub(super) fn item_to_macro_call(&mut self, src: InFile<ast::Item>) -> Option<MacroCallId> { let map = self.dyn_map(src.as_ref())?; - map[keys::ATTR_MACRO].get(&src).copied() + map[keys::ATTR_MACRO_CALL].get(&src).copied() } pub(super) fn attr_to_derive_macro_call( &mut self, item: InFile<&ast::Adt>, src: InFile<ast::Attr>, - ) -> Option<&[Option<MacroCallId>]> { + ) -> Option<(AttrId, &[Option<MacroCallId>])> { let map = self.dyn_map(item)?; - map[keys::DERIVE_MACRO].get(&src).map(AsRef::as_ref) + map[keys::DERIVE_MACRO_CALL].get(&src).map(|(id, ids)| (*id, &**ids)) } fn to_def<Ast: AstNode + 'static, ID: Copy + 'static>( @@ -328,7 +316,8 @@ impl SourceToDefCtx<'_, '_> { } pub(super) fn macro_to_def(&mut self, src: InFile<ast::Macro>) -> Option<MacroDefId> { - let makro = self.dyn_map(src.as_ref()).and_then(|it| it[keys::MACRO].get(&src).copied()); + let makro = + self.dyn_map(src.as_ref()).and_then(|it| it[keys::MACRO_CALL].get(&src).copied()); if let res @ Some(_) = makro { return res; } |