diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 94dd7f6f57d..e553fc7dceb 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -1771,6 +1771,7 @@ impl_from!( pub trait HasAttrs { fn attrs(self, db: &dyn HirDatabase) -> Attrs; + fn docs(self, db: &dyn HirDatabase) -> Option; } impl> HasAttrs for T { @@ -1778,14 +1779,8 @@ impl> HasAttrs for T { let def: AttrDef = self.into(); db.attrs(def.into()) } -} - -pub trait Docs { - fn docs(&self, db: &dyn HirDatabase) -> Option; -} -impl + Copy> Docs for T { - fn docs(&self, db: &dyn HirDatabase) -> Option { - let def: AttrDef = (*self).into(); + fn docs(self, db: &dyn HirDatabase) -> Option { + let def: AttrDef = self.into(); db.documentation(def.into()) } } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d1f4d781323..2326e3fbb79 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -34,7 +34,7 @@ mod has_source; pub use crate::{ code_model::{ Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Callable, CallableKind, - Const, Crate, CrateDependency, DefWithBody, Docs, Enum, EnumVariant, Field, FieldSource, + Const, Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, }, diff --git a/crates/ide/src/call_info.rs b/crates/ide/src/call_info.rs index 7e83a238197..7e99c6b7200 100644 --- a/crates/ide/src/call_info.rs +++ b/crates/ide/src/call_info.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here use either::Either; -use hir::{Docs, HirDisplay, Semantics, Type}; +use hir::{HasAttrs, HirDisplay, Semantics, Type}; use ide_db::RootDatabase; use stdx::format_to; use syntax::{ diff --git a/crates/ide/src/completion/complete_trait_impl.rs b/crates/ide/src/completion/complete_trait_impl.rs index 1a2b1e8a57e..26f268bd120 100644 --- a/crates/ide/src/completion/complete_trait_impl.rs +++ b/crates/ide/src/completion/complete_trait_impl.rs @@ -32,7 +32,7 @@ //! ``` use assists::utils::get_missing_assoc_items; -use hir::{self, Docs, HasSource}; +use hir::{self, HasAttrs, HasSource}; use syntax::{ ast::{self, edit, Impl}, AstNode, SyntaxKind, SyntaxNode, TextRange, T, diff --git a/crates/ide/src/completion/presentation.rs b/crates/ide/src/completion/presentation.rs index 3371aed2dfa..24c507f9b23 100644 --- a/crates/ide/src/completion/presentation.rs +++ b/crates/ide/src/completion/presentation.rs @@ -1,7 +1,7 @@ //! This modules takes care of rendering various definitions as completion items. //! It also handles scoring (sorting) completions. -use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; +use hir::{HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; use itertools::Itertools; use syntax::ast::NameOwner; use test_utils::mark;