From ec448ca4b33202e384eb034b4e15ed751355488c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 2 Jan 2021 00:42:07 +0100 Subject: Impl HasAttrs for GenericParam --- crates/hir_def/src/attr.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src/attr.rs') diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 042e119b1..86ae2f0fa 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -21,7 +21,7 @@ use crate::{ nameres::ModuleSource, path::{ModPath, PathKind}, src::HasChildSource, - AdtId, AttrDefId, Lookup, + AdtId, AttrDefId, GenericParamId, Lookup, }; /// Holds documentation @@ -235,6 +235,25 @@ impl Attrs { AttrDefId::StaticId(it) => attrs_from_item_tree(it.lookup(db).id, db), AttrDefId::FunctionId(it) => attrs_from_item_tree(it.lookup(db).id, db), AttrDefId::TypeAliasId(it) => attrs_from_item_tree(it.lookup(db).id, db), + AttrDefId::GenericParamId(it) => match it { + GenericParamId::TypeParamId(it) => { + let src = it.parent.child_source(db); + RawAttrs::from_attrs_owner( + db, + src.with_value( + src.value[it.local_id].as_ref().either(|it| it as _, |it| it as _), + ), + ) + } + GenericParamId::LifetimeParamId(it) => { + let src = it.parent.child_source(db); + RawAttrs::from_attrs_owner(db, src.with_value(&src.value[it.local_id])) + } + GenericParamId::ConstParamId(it) => { + let src = it.parent.child_source(db); + RawAttrs::from_attrs_owner(db, src.with_value(&src.value[it.local_id])) + } + }, }; raw_attrs.filter(db, def.krate(db)) -- cgit v1.2.3