Skip to content

Commit 17afa2e

Browse files
bors[bot]Veykril
andauthored
Merge #11334
11334: fix: don't panic in semantics due to `cfg_attr` disrupting offsets r=Veykril a=Veykril Reduces the panic in #11298 to an early return, that means we won't resolve these cases again for now, but this is better than constantly panicking in highlighting and hovering. bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents baa5cd9 + ebd7239 commit 17afa2e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/hir/src/semantics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,8 @@ impl<'db> SemanticsImpl<'db> {
931931
file.with_value(derive.clone()),
932932
)?;
933933
let attrs = adt_def.attrs(self.db);
934-
let mut derive_paths = attrs[attr_id].parse_path_comma_token_tree()?;
934+
// FIXME: https://github.com/rust-analyzer/rust-analyzer/issues/11298
935+
let mut derive_paths = attrs.get(attr_id)?.parse_path_comma_token_tree()?;
935936

936937
let derive_idx = tt
937938
.syntax()

crates/hir_def/src/attr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ impl ops::Deref for RawAttrs {
7272
}
7373
}
7474
}
75+
impl Attrs {
76+
pub fn get(&self, AttrId { ast_index, .. }: AttrId) -> Option<&Attr> {
77+
(**self).get(ast_index as usize)
78+
}
79+
}
7580

7681
impl ops::Deref for Attrs {
7782
type Target = [Attr];

0 commit comments

Comments
 (0)