Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/attr.rs')
| -rw-r--r-- | crates/hir_def/src/attr.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index f4d8d0d3bd..0a8fb2e47a 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -73,8 +73,8 @@ impl ops::Deref for RawAttrs { } } impl Attrs { - pub fn get(&self, AttrId { ast_index, .. }: AttrId) -> Option<&Attr> { - (**self).get(ast_index as usize) + pub fn get(&self, id: AttrId) -> Option<&Attr> { + (**self).iter().find(|attr| attr.id == id) } } @@ -89,14 +89,6 @@ impl ops::Deref for Attrs { } } -impl ops::Index<AttrId> for Attrs { - type Output = Attr; - - fn index(&self, AttrId { ast_index, .. }: AttrId) -> &Self::Output { - &(**self)[ast_index as usize] - } -} - impl ops::Deref for AttrsWithOwner { type Target = Attrs; @@ -110,7 +102,7 @@ impl RawAttrs { pub(crate) fn new(db: &dyn DefDatabase, owner: &dyn ast::HasAttrs, hygiene: &Hygiene) -> Self { let entries = collect_attrs(owner) - .flat_map(|(id, attr)| match attr { + .filter_map(|(id, attr)| match attr { Either::Left(attr) => { attr.meta().and_then(|meta| Attr::from_src(db, meta, hygiene, id)) } |