Skip to content

Commit 2a58fa0

Browse files
committed
Get rid of doctree::Trait
1 parent a3a5d2c commit 2a58fa0

File tree

3 files changed

+15
-48
lines changed

3 files changed

+15
-48
lines changed

src/librustdoc/clean/mod.rs

+14-21
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ impl Clean<Item> for doctree::Module<'_> {
234234
items.extend(self.foreigns.iter().map(|x| x.clean(cx)));
235235
items.extend(self.mods.iter().map(|x| x.clean(cx)));
236236
items.extend(self.items.iter().map(|x| x.clean(cx)).flatten());
237-
items.extend(self.traits.iter().map(|x| x.clean(cx)));
238237
items.extend(self.macros.iter().map(|x| x.clean(cx)));
239238

240239
// determine if we should display the inner contents or
@@ -1022,26 +1021,6 @@ impl Clean<FnRetTy> for hir::FnRetTy<'_> {
10221021
}
10231022
}
10241023

1025-
impl Clean<Item> for doctree::Trait<'_> {
1026-
fn clean(&self, cx: &DocContext<'_>) -> Item {
1027-
let attrs = self.attrs.clean(cx);
1028-
let is_spotlight = attrs.has_doc_flag(sym::spotlight);
1029-
Item::from_hir_id_and_parts(
1030-
self.id,
1031-
Some(self.name),
1032-
TraitItem(Trait {
1033-
unsafety: self.unsafety,
1034-
items: self.items.iter().map(|ti| ti.clean(cx)).collect(),
1035-
generics: self.generics.clean(cx),
1036-
bounds: self.bounds.clean(cx),
1037-
is_spotlight,
1038-
is_auto: self.is_auto.clean(cx),
1039-
}),
1040-
cx,
1041-
)
1042-
}
1043-
}
1044-
10451024
impl Clean<bool> for hir::IsAuto {
10461025
fn clean(&self, _: &DocContext<'_>) -> bool {
10471026
match *self {
@@ -2011,6 +1990,20 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Ident>) {
20111990
ItemKind::Fn(ref sig, ref generics, body_id) => {
20121991
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
20131992
}
1993+
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
1994+
let items =
1995+
item_ids.iter().map(|ti| cx.tcx.hir().trait_item(ti.id).clean(cx)).collect();
1996+
let attrs = item.attrs.clean(cx);
1997+
let is_spotlight = attrs.has_doc_flag(sym::spotlight);
1998+
TraitItem(Trait {
1999+
unsafety,
2000+
items,
2001+
generics: generics.clean(cx),
2002+
bounds: bounds.clean(cx),
2003+
is_spotlight,
2004+
is_auto: is_auto.clean(cx),
2005+
})
2006+
}
20142007
_ => unreachable!("not yet converted"),
20152008
};
20162009

src/librustdoc/doctree.rs

-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ crate struct Module<'hir> {
2020
crate id: hir::HirId,
2121
// (item, renamed)
2222
crate items: Vec<(&'hir hir::Item<'hir>, Option<Ident>)>,
23-
crate traits: Vec<Trait<'hir>>,
2423
crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Ident>)>,
2524
crate macros: Vec<Macro>,
2625
crate is_crate: bool,
@@ -38,7 +37,6 @@ impl Module<'hir> {
3837
imports: Vec::new(),
3938
mods: Vec::new(),
4039
items: Vec::new(),
41-
traits: Vec::new(),
4240
foreigns: Vec::new(),
4341
macros: Vec::new(),
4442
is_crate: false,
@@ -62,17 +60,6 @@ crate struct Variant<'hir> {
6260
crate def: &'hir hir::VariantData<'hir>,
6361
}
6462

65-
crate struct Trait<'hir> {
66-
crate is_auto: hir::IsAuto,
67-
crate unsafety: hir::Unsafety,
68-
crate name: Symbol,
69-
crate items: Vec<&'hir hir::TraitItem<'hir>>,
70-
crate generics: &'hir hir::Generics<'hir>,
71-
crate bounds: &'hir [hir::GenericBound<'hir>],
72-
crate attrs: &'hir [ast::Attribute],
73-
crate id: hir::HirId,
74-
}
75-
7663
// For Macro we store the DefId instead of the NodeId, since we also create
7764
// these imported macro_rules (which only have a DUMMY_NODE_ID).
7865
crate struct Macro {

src/librustdoc/visit_ast.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
319319
| hir::ItemKind::TyAlias(..)
320320
| hir::ItemKind::OpaqueTy(..)
321321
| hir::ItemKind::Static(..)
322+
| hir::ItemKind::Trait(..)
322323
| hir::ItemKind::TraitAlias(..) => om.items.push((item, renamed)),
323324
hir::ItemKind::Const(..) => {
324325
// Underscore constants do not correspond to a nameable item and
@@ -327,20 +328,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
327328
om.items.push((item, renamed));
328329
}
329330
}
330-
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
331-
let items = item_ids.iter().map(|ti| self.cx.tcx.hir().trait_item(ti.id)).collect();
332-
let t = Trait {
333-
is_auto,
334-
unsafety,
335-
name: ident.name,
336-
items,
337-
generics,
338-
bounds,
339-
id: item.hir_id,
340-
attrs: &item.attrs,
341-
};
342-
om.traits.push(t);
343-
}
344331
hir::ItemKind::Impl { ref of_trait, .. } => {
345332
// Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
346333
// them up regardless of where they're located.

0 commit comments

Comments
 (0)