mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +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
@ -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())
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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::{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user