aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-02 11:11:46 +0000
committerLukas Wirth <[email protected]>2021-01-02 11:11:46 +0000
commit68336fdb61e080e1bfb008fd7742ee22ccc51829 (patch)
treee60c618ae8143017bf5186f4b7e3eb73b58535c4 /crates
parentec448ca4b33202e384eb034b4e15ed751355488c (diff)
Implement HasAttrs for Type-, Const- and LifetimeParam
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/attrs.rs19
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;
10use syntax::ast; 10use syntax::ast;
11 11
12use crate::{ 12use 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
17pub trait HasAttrs { 17pub trait HasAttrs {
@@ -65,23 +65,24 @@ impl_has_attrs![
65 (GenericParam, GenericParamId), 65 (GenericParam, GenericParamId),
66]; 66];
67 67
68macro_rules! impl_has_attrs_adt { 68macro_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
84impl_has_attrs_adt![Struct, Union, Enum]; 84impl_has_attrs_enum![Struct, Union, Enum for Adt];
85impl_has_attrs_enum![TypeParam, ConstParam, LifetimeParam for GenericParam];
85 86
86fn resolve_doc_path( 87fn resolve_doc_path(
87 db: &dyn HirDatabase, 88 db: &dyn HirDatabase,