diff options
author | Lukas Wirth <[email protected]> | 2021-01-02 11:11:46 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-01-02 11:11:46 +0000 |
commit | 68336fdb61e080e1bfb008fd7742ee22ccc51829 (patch) | |
tree | e60c618ae8143017bf5186f4b7e3eb73b58535c4 | |
parent | ec448ca4b33202e384eb034b4e15ed751355488c (diff) |
Implement HasAttrs for Type-, Const- and LifetimeParam
-rw-r--r-- | crates/hir/src/attrs.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs index a027f881e..99fb65bac 100644 --- a/crates/hir/src/attrs.rs +++ b/crates/hir/src/attrs.rs | |||
@@ -10,8 +10,8 @@ use hir_ty::db::HirDatabase; | |||
10 | use syntax::ast; | 10 | use syntax::ast; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | Adt, Const, Enum, Field, Function, GenericParam, MacroDef, Module, ModuleDef, Static, Struct, | 13 | Adt, Const, ConstParam, Enum, Field, Function, GenericParam, LifetimeParam, MacroDef, Module, |
14 | Trait, TypeAlias, Union, Variant, | 14 | ModuleDef, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant, |
15 | }; | 15 | }; |
16 | 16 | ||
17 | pub trait HasAttrs { | 17 | pub trait HasAttrs { |
@@ -65,23 +65,24 @@ impl_has_attrs![ | |||
65 | (GenericParam, GenericParamId), | 65 | (GenericParam, GenericParamId), |
66 | ]; | 66 | ]; |
67 | 67 | ||
68 | macro_rules! impl_has_attrs_adt { | 68 | macro_rules! impl_has_attrs_enum { |
69 | ($($adt:ident),*) => {$( | 69 | ($($variant:ident),* for $enum:ident) => {$( |
70 | impl HasAttrs for $adt { | 70 | impl HasAttrs for $variant { |
71 | fn attrs(self, db: &dyn HirDatabase) -> Attrs { | 71 | fn attrs(self, db: &dyn HirDatabase) -> Attrs { |
72 | Adt::$adt(self).attrs(db) | 72 | $enum::$variant(self).attrs(db) |
73 | } | 73 | } |
74 | fn docs(self, db: &dyn HirDatabase) -> Option<Documentation> { | 74 | fn docs(self, db: &dyn HirDatabase) -> Option<Documentation> { |
75 | Adt::$adt(self).docs(db) | 75 | $enum::$variant(self).docs(db) |
76 | } | 76 | } |
77 | fn resolve_doc_path(self, db: &dyn HirDatabase, link: &str, ns: Option<Namespace>) -> Option<ModuleDef> { | 77 | fn resolve_doc_path(self, db: &dyn HirDatabase, link: &str, ns: Option<Namespace>) -> Option<ModuleDef> { |
78 | Adt::$adt(self).resolve_doc_path(db, link, ns) | 78 | $enum::$variant(self).resolve_doc_path(db, link, ns) |
79 | } | 79 | } |
80 | } | 80 | } |
81 | )*}; | 81 | )*}; |
82 | } | 82 | } |
83 | 83 | ||
84 | impl_has_attrs_adt![Struct, Union, Enum]; | 84 | impl_has_attrs_enum![Struct, Union, Enum for Adt]; |
85 | impl_has_attrs_enum![TypeParam, ConstParam, LifetimeParam for GenericParam]; | ||
85 | 86 | ||
86 | fn resolve_doc_path( | 87 | fn resolve_doc_path( |
87 | db: &dyn HirDatabase, | 88 | db: &dyn HirDatabase, |