Merge #11334
11334: fix: don't panic in semantics due to `cfg_attr` disrupting offsets r=Veykril a=Veykril Reduces the panic in https://github.com/rust-analyzer/rust-analyzer/issues/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>
This commit is contained in:
commit
17afa2e778
@ -931,7 +931,8 @@ fn resolve_derive_ident(
|
||||
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()
|
||||
|
@ -72,6 +72,11 @@ fn deref(&self) -> &[Attr] {
|
||||
}
|
||||
}
|
||||
}
|
||||
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];
|
||||
|
Loading…
Reference in New Issue
Block a user