diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 9596e81818..2bffb12dee 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -931,7 +931,8 @@ impl<'db> SemanticsImpl<'db> { file.with_value(derive.clone()), )?; let attrs = adt_def.attrs(self.db); - let mut derive_paths = attrs[attr_id].parse_path_comma_token_tree()?; + // FIXME: https://github.com/rust-analyzer/rust-analyzer/issues/11298 + let mut derive_paths = attrs.get(attr_id)?.parse_path_comma_token_tree()?; let derive_idx = tt .syntax() diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index b4ddfba0d0..98177f4301 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -72,6 +72,11 @@ impl ops::Deref for RawAttrs { } } } +impl Attrs { + pub fn get(&self, AttrId { ast_index, .. }: AttrId) -> Option<&Attr> { + (**self).get(ast_index as usize) + } +} impl ops::Deref for Attrs { type Target = [Attr];