mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
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:
parent
59c77ff062
commit
b45dd9ef54
5 changed files with 7 additions and 12 deletions
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue