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.rs48
1 files changed, 12 insertions, 36 deletions
diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs
index fcd92ad338..200072c172 100644
--- a/crates/hir-def/src/attr.rs
+++ b/crates/hir-def/src/attr.rs
@@ -300,6 +300,7 @@ impl AttrsWithOwner {
AdtId::UnionId(it) => attrs_from_item_tree(it.lookup(db).id, db),
},
AttrDefId::TraitId(it) => attrs_from_item_tree(it.lookup(db).id, db),
+ AttrDefId::TraitAliasId(it) => attrs_from_item_tree(it.lookup(db).id, db),
AttrDefId::MacroId(it) => match it {
MacroId::Macro2Id(it) => attrs_from_item_tree(it.lookup(db).id, db),
MacroId::MacroRulesId(it) => attrs_from_item_tree(it.lookup(db).id, db),
@@ -315,26 +316,14 @@ impl AttrsWithOwner {
let src = it.parent().child_source(db);
RawAttrs::from_attrs_owner(
db.upcast(),
- src.with_value(src.value[it.local_id()].as_ref().either(
- |it| match it {
- ast::TypeOrConstParam::Type(it) => it as _,
- ast::TypeOrConstParam::Const(it) => it as _,
- },
- |it| it as _,
- )),
+ src.with_value(&src.value[it.local_id()]),
)
}
GenericParamId::TypeParamId(it) => {
let src = it.parent().child_source(db);
RawAttrs::from_attrs_owner(
db.upcast(),
- src.with_value(src.value[it.local_id()].as_ref().either(
- |it| match it {
- ast::TypeOrConstParam::Type(it) => it as _,
- ast::TypeOrConstParam::Const(it) => it as _,
- },
- |it| it as _,
- )),
+ src.with_value(&src.value[it.local_id()]),
)
}
GenericParamId::LifetimeParamId(it) => {
@@ -404,6 +393,7 @@ impl AttrsWithOwner {
AttrDefId::StaticId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::ConstId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::TraitId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
+ AttrDefId::TraitAliasId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::TypeAliasId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::MacroId(id) => match id {
MacroId::Macro2Id(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
@@ -412,28 +402,14 @@ impl AttrsWithOwner {
},
AttrDefId::ImplId(id) => id.lookup(db).source(db).map(ast::AnyHasAttrs::new),
AttrDefId::GenericParamId(id) => match id {
- GenericParamId::ConstParamId(id) => {
- id.parent().child_source(db).map(|source| match &source[id.local_id()] {
- Either::Left(ast::TypeOrConstParam::Type(id)) => {
- ast::AnyHasAttrs::new(id.clone())
- }
- Either::Left(ast::TypeOrConstParam::Const(id)) => {
- ast::AnyHasAttrs::new(id.clone())
- }
- Either::Right(id) => ast::AnyHasAttrs::new(id.clone()),
- })
- }
- GenericParamId::TypeParamId(id) => {
- id.parent().child_source(db).map(|source| match &source[id.local_id()] {
- Either::Left(ast::TypeOrConstParam::Type(id)) => {
- ast::AnyHasAttrs::new(id.clone())
- }
- Either::Left(ast::TypeOrConstParam::Const(id)) => {
- ast::AnyHasAttrs::new(id.clone())
- }
- Either::Right(id) => ast::AnyHasAttrs::new(id.clone()),
- })
- }
+ GenericParamId::ConstParamId(id) => id
+ .parent()
+ .child_source(db)
+ .map(|source| ast::AnyHasAttrs::new(source[id.local_id()].clone())),
+ GenericParamId::TypeParamId(id) => id
+ .parent()
+ .child_source(db)
+ .map(|source| ast::AnyHasAttrs::new(source[id.local_id()].clone())),
GenericParamId::LifetimeParamId(id) => id
.parent
.child_source(db)