Use the same abstraction for attrs and docs

Doc comments *are* attributes, so there's no reason to have two crates
here.
This commit is contained in:
Aleksey Kladov 2020-08-25 12:13:31 +02:00
parent 59c77ff062
commit b45dd9ef54
5 changed files with 7 additions and 12 deletions

View file

@ -1771,6 +1771,7 @@ impl_from!(
pub trait HasAttrs {
fn attrs(self, db: &dyn HirDatabase) -> Attrs;
fn docs(self, db: &dyn HirDatabase) -> Option<Documentation>;
}
impl<T: Into<AttrDef>> HasAttrs for T {
@ -1778,14 +1779,8 @@ impl<T: Into<AttrDef>> HasAttrs for T {
let def: AttrDef = self.into();
db.attrs(def.into())
}
}
pub trait Docs {
fn docs(&self, db: &dyn HirDatabase) -> Option<Documentation>;
}
impl<T: Into<AttrDef> + Copy> Docs for T {
fn docs(&self, db: &dyn HirDatabase) -> Option<Documentation> {
let def: AttrDef = (*self).into();
fn docs(self, db: &dyn HirDatabase) -> Option<Documentation> {
let def: AttrDef = self.into();
db.documentation(def.into())
}
}