diff options
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 496b4ee8a..4b3ec5457 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | pub(crate) mod src; | 3 | pub(crate) mod src; |
4 | pub(crate) mod docs; | ||
5 | 4 | ||
6 | use std::sync::Arc; | 5 | use std::sync::Arc; |
7 | 6 | ||
@@ -9,11 +8,12 @@ use hir_def::{ | |||
9 | adt::VariantData, | 8 | adt::VariantData, |
10 | body::scope::ExprScopes, | 9 | body::scope::ExprScopes, |
11 | builtin_type::BuiltinType, | 10 | builtin_type::BuiltinType, |
11 | docs::Documentation, | ||
12 | nameres::per_ns::PerNs, | 12 | nameres::per_ns::PerNs, |
13 | resolver::{HasResolver, TypeNs}, | 13 | resolver::{HasResolver, TypeNs}, |
14 | type_ref::TypeRef, | 14 | type_ref::TypeRef, |
15 | AdtId, ContainerId, CrateModuleId, EnumVariantId, HasModule, ImplId, LocalEnumVariantId, | 15 | ContainerId, CrateModuleId, HasModule, ImplId, LocalEnumVariantId, LocalStructFieldId, Lookup, |
16 | LocalStructFieldId, Lookup, ModuleId, StructFieldId, UnionId, | 16 | ModuleId, UnionId, |
17 | }; | 17 | }; |
18 | use hir_expand::{ | 18 | use hir_expand::{ |
19 | diagnostics::DiagnosticSink, | 19 | diagnostics::DiagnosticSink, |
@@ -1024,18 +1024,17 @@ pub trait HasAttrs { | |||
1024 | 1024 | ||
1025 | impl<T: Into<AttrDef>> HasAttrs for T { | 1025 | impl<T: Into<AttrDef>> HasAttrs for T { |
1026 | fn attrs(self, db: &impl DefDatabase) -> Attrs { | 1026 | fn attrs(self, db: &impl DefDatabase) -> Attrs { |
1027 | let def = self.into(); | 1027 | let def: AttrDef = self.into(); |
1028 | match def { | 1028 | db.attrs(def.into()) |
1029 | AttrDef::Module(it) => db.attrs(it.id.into()), | 1029 | } |
1030 | AttrDef::StructField(it) => db.attrs(StructFieldId::from(it).into()), | 1030 | } |
1031 | AttrDef::Adt(it) => db.attrs(AdtId::from(it).into()), | 1031 | |
1032 | AttrDef::Function(it) => db.attrs(it.id.into()), | 1032 | pub trait Docs { |
1033 | AttrDef::EnumVariant(it) => db.attrs(EnumVariantId::from(it).into()), | 1033 | fn docs(&self, db: &impl HirDatabase) -> Option<Documentation>; |
1034 | AttrDef::Static(it) => db.attrs(it.id.into()), | 1034 | } |
1035 | AttrDef::Const(it) => db.attrs(it.id.into()), | 1035 | impl<T: Into<AttrDef> + Copy> Docs for T { |
1036 | AttrDef::Trait(it) => db.attrs(it.id.into()), | 1036 | fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> { |
1037 | AttrDef::TypeAlias(it) => db.attrs(it.id.into()), | 1037 | let def: AttrDef = (*self).into(); |
1038 | AttrDef::MacroDef(it) => db.attrs(it.id.into()), | 1038 | db.documentation(def.into()) |
1039 | } | ||
1040 | } | 1039 | } |
1041 | } | 1040 | } |