Get rid of doctree::Trait
This commit is contained in:
parent
a3a5d2cd13
commit
2a58fa0682
@ -234,7 +234,6 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
items.extend(self.foreigns.iter().map(|x| x.clean(cx)));
|
||||
items.extend(self.mods.iter().map(|x| x.clean(cx)));
|
||||
items.extend(self.items.iter().map(|x| x.clean(cx)).flatten());
|
||||
items.extend(self.traits.iter().map(|x| x.clean(cx)));
|
||||
items.extend(self.macros.iter().map(|x| x.clean(cx)));
|
||||
|
||||
// determine if we should display the inner contents or
|
||||
@ -1022,26 +1021,6 @@ fn clean(&self, cx: &DocContext<'_>) -> FnRetTy {
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Trait<'_> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let attrs = self.attrs.clean(cx);
|
||||
let is_spotlight = attrs.has_doc_flag(sym::spotlight);
|
||||
Item::from_hir_id_and_parts(
|
||||
self.id,
|
||||
Some(self.name),
|
||||
TraitItem(Trait {
|
||||
unsafety: self.unsafety,
|
||||
items: self.items.iter().map(|ti| ti.clean(cx)).collect(),
|
||||
generics: self.generics.clean(cx),
|
||||
bounds: self.bounds.clean(cx),
|
||||
is_spotlight,
|
||||
is_auto: self.is_auto.clean(cx),
|
||||
}),
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<bool> for hir::IsAuto {
|
||||
fn clean(&self, _: &DocContext<'_>) -> bool {
|
||||
match *self {
|
||||
@ -2011,6 +1990,20 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
|
||||
ItemKind::Fn(ref sig, ref generics, body_id) => {
|
||||
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
|
||||
}
|
||||
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
|
||||
let items =
|
||||
item_ids.iter().map(|ti| cx.tcx.hir().trait_item(ti.id).clean(cx)).collect();
|
||||
let attrs = item.attrs.clean(cx);
|
||||
let is_spotlight = attrs.has_doc_flag(sym::spotlight);
|
||||
TraitItem(Trait {
|
||||
unsafety,
|
||||
items,
|
||||
generics: generics.clean(cx),
|
||||
bounds: bounds.clean(cx),
|
||||
is_spotlight,
|
||||
is_auto: is_auto.clean(cx),
|
||||
})
|
||||
}
|
||||
_ => unreachable!("not yet converted"),
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
crate id: hir::HirId,
|
||||
// (item, renamed)
|
||||
crate items: Vec<(&'hir hir::Item<'hir>, Option<Ident>)>,
|
||||
crate traits: Vec<Trait<'hir>>,
|
||||
crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Ident>)>,
|
||||
crate macros: Vec<Macro>,
|
||||
crate is_crate: bool,
|
||||
@ -38,7 +37,6 @@ impl Module<'hir> {
|
||||
imports: Vec::new(),
|
||||
mods: Vec::new(),
|
||||
items: Vec::new(),
|
||||
traits: Vec::new(),
|
||||
foreigns: Vec::new(),
|
||||
macros: Vec::new(),
|
||||
is_crate: false,
|
||||
@ -62,17 +60,6 @@ impl Module<'hir> {
|
||||
crate def: &'hir hir::VariantData<'hir>,
|
||||
}
|
||||
|
||||
crate struct Trait<'hir> {
|
||||
crate is_auto: hir::IsAuto,
|
||||
crate unsafety: hir::Unsafety,
|
||||
crate name: Symbol,
|
||||
crate items: Vec<&'hir hir::TraitItem<'hir>>,
|
||||
crate generics: &'hir hir::Generics<'hir>,
|
||||
crate bounds: &'hir [hir::GenericBound<'hir>],
|
||||
crate attrs: &'hir [ast::Attribute],
|
||||
crate id: hir::HirId,
|
||||
}
|
||||
|
||||
// For Macro we store the DefId instead of the NodeId, since we also create
|
||||
// these imported macro_rules (which only have a DUMMY_NODE_ID).
|
||||
crate struct Macro {
|
||||
|
@ -319,6 +319,7 @@ fn visit_item(
|
||||
| hir::ItemKind::TyAlias(..)
|
||||
| hir::ItemKind::OpaqueTy(..)
|
||||
| hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Trait(..)
|
||||
| hir::ItemKind::TraitAlias(..) => om.items.push((item, renamed)),
|
||||
hir::ItemKind::Const(..) => {
|
||||
// Underscore constants do not correspond to a nameable item and
|
||||
@ -327,20 +328,6 @@ fn visit_item(
|
||||
om.items.push((item, renamed));
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
|
||||
let items = item_ids.iter().map(|ti| self.cx.tcx.hir().trait_item(ti.id)).collect();
|
||||
let t = Trait {
|
||||
is_auto,
|
||||
unsafety,
|
||||
name: ident.name,
|
||||
items,
|
||||
generics,
|
||||
bounds,
|
||||
id: item.hir_id,
|
||||
attrs: &item.attrs,
|
||||
};
|
||||
om.traits.push(t);
|
||||
}
|
||||
hir::ItemKind::Impl { ref of_trait, .. } => {
|
||||
// Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
|
||||
// them up regardless of where they're located.
|
||||
|
Loading…
Reference in New Issue
Block a user