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.rs42
1 files changed, 27 insertions, 15 deletions
diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs
index c91a549726..519706c65f 100644
--- a/crates/hir-def/src/attr.rs
+++ b/crates/hir-def/src/attr.rs
@@ -377,27 +377,39 @@ impl AttrsWithOwner {
AttrDefId::GenericParamId(it) => match it {
GenericParamId::ConstParamId(it) => {
let src = it.parent().child_source(db);
- RawAttrs::from_attrs_owner(
- db.upcast(),
- src.with_value(&src.value[it.local_id()]),
- db.span_map(src.file_id).as_ref(),
- )
+ // FIXME: We should be never getting `None` here.
+ match src.value.get(it.local_id()) {
+ Some(val) => RawAttrs::from_attrs_owner(
+ db.upcast(),
+ src.with_value(val),
+ db.span_map(src.file_id).as_ref(),
+ ),
+ None => RawAttrs::EMPTY,
+ }
}
GenericParamId::TypeParamId(it) => {
let src = it.parent().child_source(db);
- RawAttrs::from_attrs_owner(
- db.upcast(),
- src.with_value(&src.value[it.local_id()]),
- db.span_map(src.file_id).as_ref(),
- )
+ // FIXME: We should be never getting `None` here.
+ match src.value.get(it.local_id()) {
+ Some(val) => RawAttrs::from_attrs_owner(
+ db.upcast(),
+ src.with_value(val),
+ db.span_map(src.file_id).as_ref(),
+ ),
+ None => RawAttrs::EMPTY,
+ }
}
GenericParamId::LifetimeParamId(it) => {
let src = it.parent.child_source(db);
- RawAttrs::from_attrs_owner(
- db.upcast(),
- src.with_value(&src.value[it.local_id]),
- db.span_map(src.file_id).as_ref(),
- )
+ // FIXME: We should be never getting `None` here.
+ match src.value.get(it.local_id) {
+ Some(val) => RawAttrs::from_attrs_owner(
+ db.upcast(),
+ src.with_value(val),
+ db.span_map(src.file_id).as_ref(),
+ ),
+ None => RawAttrs::EMPTY,
+ }
}
},
AttrDefId::ExternBlockId(it) => attrs_from_item_tree_loc(db, it),