aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-25 11:13:31 +0100
committerAleksey Kladov <[email protected]>2020-08-25 11:13:31 +0100
commitb45dd9ef54c668b714c6fc41bc42d415ed772f32 (patch)
treebf97e30a7e9b806f36fc26c153951181884debfa /crates/hir
parent59c77ff062e2b1668fcfa885a8438c333b4f0875 (diff)
Use the same abstraction for attrs and docs
Doc comments *are* attributes, so there's no reason to have two crates here.
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/code_model.rs11
-rw-r--r--crates/hir/src/lib.rs2
2 files changed, 4 insertions, 9 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 94dd7f6f5..e553fc7dc 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -1771,6 +1771,7 @@ impl_from!(
1771 1771
1772pub trait HasAttrs { 1772pub trait HasAttrs {
1773 fn attrs(self, db: &dyn HirDatabase) -> Attrs; 1773 fn attrs(self, db: &dyn HirDatabase) -> Attrs;
1774 fn docs(self, db: &dyn HirDatabase) -> Option<Documentation>;
1774} 1775}
1775 1776
1776impl<T: Into<AttrDef>> HasAttrs for T { 1777impl<T: Into<AttrDef>> HasAttrs for T {
@@ -1778,14 +1779,8 @@ impl<T: Into<AttrDef>> HasAttrs for T {
1778 let def: AttrDef = self.into(); 1779 let def: AttrDef = self.into();
1779 db.attrs(def.into()) 1780 db.attrs(def.into())
1780 } 1781 }
1781} 1782 fn docs(self, db: &dyn HirDatabase) -> Option<Documentation> {
1782 1783 let def: AttrDef = self.into();
1783pub trait Docs {
1784 fn docs(&self, db: &dyn HirDatabase) -> Option<Documentation>;
1785}
1786impl<T: Into<AttrDef> + Copy> Docs for T {
1787 fn docs(&self, db: &dyn HirDatabase) -> Option<Documentation> {
1788 let def: AttrDef = (*self).into();
1789 db.documentation(def.into()) 1784 db.documentation(def.into())
1790 } 1785 }
1791} 1786}
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index d1f4d7813..2326e3fbb 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -34,7 +34,7 @@ mod has_source;
34pub use crate::{ 34pub use crate::{
35 code_model::{ 35 code_model::{
36 Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Callable, CallableKind, 36 Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Callable, CallableKind,
37 Const, Crate, CrateDependency, DefWithBody, Docs, Enum, EnumVariant, Field, FieldSource, 37 Const, Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource,
38 Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, 38 Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef,
39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, 39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
40 }, 40 },