Skip to content

Commit 0e1a302

Browse files
committed
Remove dead code in rustdoc::doctree
It was completely unused.
1 parent fc4ca55 commit 0e1a302

File tree

3 files changed

+18
-147
lines changed

3 files changed

+18
-147
lines changed

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
22802280
}
22812281
}
22822282

2283-
impl Clean<Item> for doctree::Macro<'_> {
2283+
impl Clean<Item> for doctree::Macro {
22842284
fn clean(&self, cx: &DocContext<'_>) -> Item {
22852285
Item::from_def_id_and_parts(
22862286
self.def_id,
@@ -2301,7 +2301,7 @@ impl Clean<Item> for doctree::Macro<'_> {
23012301
}
23022302
}
23032303

2304-
impl Clean<Item> for doctree::ProcMacro<'_> {
2304+
impl Clean<Item> for doctree::ProcMacro {
23052305
fn clean(&self, cx: &DocContext<'_>) -> Item {
23062306
Item::from_hir_id_and_parts(
23072307
self.id,

src/librustdoc/doctree.rs

+5-47
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,19 @@ crate struct Module<'hir> {
2828
crate statics: Vec<Static<'hir>>,
2929
crate constants: Vec<Constant<'hir>>,
3030
crate traits: Vec<Trait<'hir>>,
31-
crate vis: &'hir hir::Visibility<'hir>,
3231
crate impls: Vec<Impl<'hir>>,
3332
crate foreigns: Vec<ForeignItem<'hir>>,
34-
crate macros: Vec<Macro<'hir>>,
35-
crate proc_macros: Vec<ProcMacro<'hir>>,
33+
crate macros: Vec<Macro>,
34+
crate proc_macros: Vec<ProcMacro>,
3635
crate trait_aliases: Vec<TraitAlias<'hir>>,
3736
crate is_crate: bool,
3837
}
3938

4039
impl Module<'hir> {
41-
crate fn new(
42-
name: Option<Symbol>,
43-
attrs: &'hir [ast::Attribute],
44-
vis: &'hir hir::Visibility<'hir>,
45-
) -> Module<'hir> {
40+
crate fn new(name: Option<Symbol>, attrs: &'hir [ast::Attribute]) -> Module<'hir> {
4641
Module {
4742
name,
4843
id: hir::CRATE_HIR_ID,
49-
vis,
5044
where_outer: rustc_span::DUMMY_SP,
5145
where_inner: rustc_span::DUMMY_SP,
5246
attrs,
@@ -83,53 +77,39 @@ crate enum StructType {
8377
}
8478

8579
crate struct Struct<'hir> {
86-
crate vis: &'hir hir::Visibility<'hir>,
8780
crate id: hir::HirId,
8881
crate struct_type: StructType,
8982
crate name: Symbol,
9083
crate generics: &'hir hir::Generics<'hir>,
91-
crate attrs: &'hir [ast::Attribute],
9284
crate fields: &'hir [hir::StructField<'hir>],
93-
crate span: Span,
9485
}
9586

9687
crate struct Union<'hir> {
97-
crate vis: &'hir hir::Visibility<'hir>,
9888
crate id: hir::HirId,
9989
crate struct_type: StructType,
10090
crate name: Symbol,
10191
crate generics: &'hir hir::Generics<'hir>,
102-
crate attrs: &'hir [ast::Attribute],
10392
crate fields: &'hir [hir::StructField<'hir>],
104-
crate span: Span,
10593
}
10694

10795
crate struct Enum<'hir> {
108-
crate vis: &'hir hir::Visibility<'hir>,
10996
crate variants: Vec<Variant<'hir>>,
11097
crate generics: &'hir hir::Generics<'hir>,
111-
crate attrs: &'hir [ast::Attribute],
11298
crate id: hir::HirId,
113-
crate span: Span,
11499
crate name: Symbol,
115100
}
116101

117102
crate struct Variant<'hir> {
118103
crate name: Symbol,
119104
crate id: hir::HirId,
120-
crate attrs: &'hir [ast::Attribute],
121105
crate def: &'hir hir::VariantData<'hir>,
122-
crate span: Span,
123106
}
124107

125108
crate struct Function<'hir> {
126109
crate decl: &'hir hir::FnDecl<'hir>,
127-
crate attrs: &'hir [ast::Attribute],
128110
crate id: hir::HirId,
129111
crate name: Symbol,
130-
crate vis: &'hir hir::Visibility<'hir>,
131112
crate header: hir::FnHeader,
132-
crate span: Span,
133113
crate generics: &'hir hir::Generics<'hir>,
134114
crate body: hir::BodyId,
135115
}
@@ -139,18 +119,12 @@ crate struct Typedef<'hir> {
139119
crate gen: &'hir hir::Generics<'hir>,
140120
crate name: Symbol,
141121
crate id: hir::HirId,
142-
crate attrs: &'hir [ast::Attribute],
143-
crate span: Span,
144-
crate vis: &'hir hir::Visibility<'hir>,
145122
}
146123

147124
crate struct OpaqueTy<'hir> {
148125
crate opaque_ty: &'hir hir::OpaqueTy<'hir>,
149126
crate name: Symbol,
150127
crate id: hir::HirId,
151-
crate attrs: &'hir [ast::Attribute],
152-
crate span: Span,
153-
crate vis: &'hir hir::Visibility<'hir>,
154128
}
155129

156130
#[derive(Debug)]
@@ -169,10 +143,7 @@ crate struct Constant<'hir> {
169143
crate type_: &'hir hir::Ty<'hir>,
170144
crate expr: hir::BodyId,
171145
crate name: Symbol,
172-
crate attrs: &'hir [ast::Attribute],
173-
crate vis: &'hir hir::Visibility<'hir>,
174146
crate id: hir::HirId,
175-
crate span: Span,
176147
}
177148

178149
crate struct Trait<'hir> {
@@ -184,18 +155,13 @@ crate struct Trait<'hir> {
184155
crate bounds: &'hir [hir::GenericBound<'hir>],
185156
crate attrs: &'hir [ast::Attribute],
186157
crate id: hir::HirId,
187-
crate span: Span,
188-
crate vis: &'hir hir::Visibility<'hir>,
189158
}
190159

191160
crate struct TraitAlias<'hir> {
192161
crate name: Symbol,
193162
crate generics: &'hir hir::Generics<'hir>,
194163
crate bounds: &'hir [hir::GenericBound<'hir>],
195-
crate attrs: &'hir [ast::Attribute],
196164
crate id: hir::HirId,
197-
crate span: Span,
198-
crate vis: &'hir hir::Visibility<'hir>,
199165
}
200166

201167
#[derive(Debug)]
@@ -215,22 +181,16 @@ crate struct Impl<'hir> {
215181
}
216182

217183
crate struct ForeignItem<'hir> {
218-
crate vis: &'hir hir::Visibility<'hir>,
219184
crate id: hir::HirId,
220185
crate name: Symbol,
221186
crate kind: &'hir hir::ForeignItemKind<'hir>,
222-
crate attrs: &'hir [ast::Attribute],
223-
crate span: Span,
224187
}
225188

226189
// For Macro we store the DefId instead of the NodeId, since we also create
227190
// these imported macro_rules (which only have a DUMMY_NODE_ID).
228-
crate struct Macro<'hir> {
191+
crate struct Macro {
229192
crate name: Symbol,
230-
crate hid: hir::HirId,
231193
crate def_id: hir::def_id::DefId,
232-
crate attrs: &'hir [ast::Attribute],
233-
crate span: Span,
234194
crate matchers: Vec<Span>,
235195
crate imported_from: Option<Symbol>,
236196
}
@@ -256,13 +216,11 @@ crate struct Import<'hir> {
256216
crate span: Span,
257217
}
258218

259-
crate struct ProcMacro<'hir> {
219+
crate struct ProcMacro {
260220
crate name: Symbol,
261221
crate id: hir::HirId,
262222
crate kind: MacroKind,
263223
crate helpers: Vec<Symbol>,
264-
crate attrs: &'hir [ast::Attribute],
265-
crate span: Span,
266224
}
267225

268226
crate fn struct_type_from_def(vdata: &hir::VariantData<'_>) -> StructType {

src/librustdoc/visit_ast.rs

+11-98
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
9191
) -> Struct<'tcx> {
9292
debug!("visiting struct");
9393
let struct_type = struct_type_from_def(&*sd);
94-
Struct {
95-
id: item.hir_id,
96-
struct_type,
97-
name,
98-
vis: &item.vis,
99-
attrs: &item.attrs,
100-
generics,
101-
fields: sd.fields(),
102-
span: item.span,
103-
}
94+
Struct { id: item.hir_id, struct_type, name, generics, fields: sd.fields() }
10495
}
10596

10697
fn visit_union_data(
@@ -112,16 +103,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
112103
) -> Union<'tcx> {
113104
debug!("visiting union");
114105
let struct_type = struct_type_from_def(&*sd);
115-
Union {
116-
id: item.hir_id,
117-
struct_type,
118-
name,
119-
vis: &item.vis,
120-
attrs: &item.attrs,
121-
generics,
122-
fields: sd.fields(),
123-
span: item.span,
124-
}
106+
Union { id: item.hir_id, struct_type, name, generics, fields: sd.fields() }
125107
}
126108

127109
fn visit_enum_def(
@@ -137,19 +119,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
137119
variants: def
138120
.variants
139121
.iter()
140-
.map(|v| Variant {
141-
name: v.ident.name,
142-
id: v.id,
143-
attrs: &v.attrs,
144-
def: &v.data,
145-
span: v.span,
146-
})
122+
.map(|v| Variant { name: v.ident.name, id: v.id, def: &v.data })
147123
.collect(),
148-
vis: &it.vis,
149124
generics,
150-
attrs: &it.attrs,
151125
id: it.hir_id,
152-
span: it.span,
153126
}
154127
}
155128

@@ -202,27 +175,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
202175
}
203176
}
204177

205-
om.proc_macros.push(ProcMacro {
206-
name,
207-
id: item.hir_id,
208-
kind,
209-
helpers,
210-
attrs: &item.attrs,
211-
span: item.span,
212-
});
178+
om.proc_macros.push(ProcMacro { name, id: item.hir_id, kind, helpers });
213179
}
214180
None => {
215-
om.fns.push(Function {
216-
id: item.hir_id,
217-
vis: &item.vis,
218-
attrs: &item.attrs,
219-
decl,
220-
name,
221-
span: item.span,
222-
generics,
223-
header,
224-
body,
225-
});
181+
om.fns.push(Function { id: item.hir_id, decl, name, generics, header, body });
226182
}
227183
}
228184
}
@@ -236,7 +192,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
236192
m: &'tcx hir::Mod<'tcx>,
237193
name: Option<Symbol>,
238194
) -> Module<'tcx> {
239-
let mut om = Module::new(name, attrs, vis);
195+
let mut om = Module::new(name, attrs);
240196
om.where_outer = span;
241197
om.where_inner = m.inner;
242198
om.id = id;
@@ -471,26 +427,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
471427
self.visit_fn(om, item, ident.name, &sig.decl, sig.header, gen, body)
472428
}
473429
hir::ItemKind::TyAlias(ty, ref gen) => {
474-
let t = Typedef {
475-
ty,
476-
gen,
477-
name: ident.name,
478-
id: item.hir_id,
479-
attrs: &item.attrs,
480-
span: item.span,
481-
vis: &item.vis,
482-
};
430+
let t = Typedef { ty, gen, name: ident.name, id: item.hir_id };
483431
om.typedefs.push(t);
484432
}
485433
hir::ItemKind::OpaqueTy(ref opaque_ty) => {
486-
let t = OpaqueTy {
487-
opaque_ty,
488-
name: ident.name,
489-
id: item.hir_id,
490-
attrs: &item.attrs,
491-
span: item.span,
492-
vis: &item.vis,
493-
};
434+
let t = OpaqueTy { opaque_ty, name: ident.name, id: item.hir_id };
494435
om.opaque_tys.push(t);
495436
}
496437
hir::ItemKind::Static(type_, mutability, expr) => {
@@ -510,15 +451,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
510451
// Underscore constants do not correspond to a nameable item and
511452
// so are never useful in documentation.
512453
if ident.name != kw::Underscore {
513-
let s = Constant {
514-
type_,
515-
expr,
516-
id: item.hir_id,
517-
name: ident.name,
518-
attrs: &item.attrs,
519-
span: item.span,
520-
vis: &item.vis,
521-
};
454+
let s = Constant { type_, expr, id: item.hir_id, name: ident.name };
522455
om.constants.push(s);
523456
}
524457
}
@@ -533,21 +466,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
533466
bounds,
534467
id: item.hir_id,
535468
attrs: &item.attrs,
536-
span: item.span,
537-
vis: &item.vis,
538469
};
539470
om.traits.push(t);
540471
}
541472
hir::ItemKind::TraitAlias(ref generics, ref bounds) => {
542-
let t = TraitAlias {
543-
name: ident.name,
544-
generics,
545-
bounds,
546-
id: item.hir_id,
547-
attrs: &item.attrs,
548-
span: item.span,
549-
vis: &item.vis,
550-
};
473+
let t = TraitAlias { name: ident.name, generics, bounds, id: item.hir_id };
551474
om.trait_aliases.push(t);
552475
}
553476

@@ -602,29 +525,19 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
602525
id: item.hir_id,
603526
name: renamed.unwrap_or(item.ident).name,
604527
kind: &item.kind,
605-
vis: &item.vis,
606-
attrs: &item.attrs,
607-
span: item.span,
608528
});
609529
}
610530

611531
// Convert each `exported_macro` into a doc item.
612-
fn visit_local_macro(
613-
&self,
614-
def: &'tcx hir::MacroDef<'_>,
615-
renamed: Option<Symbol>,
616-
) -> Macro<'tcx> {
532+
fn visit_local_macro(&self, def: &'tcx hir::MacroDef<'_>, renamed: Option<Symbol>) -> Macro {
617533
debug!("visit_local_macro: {}", def.ident);
618534
let tts = def.ast.body.inner_tokens().trees().collect::<Vec<_>>();
619535
// Extract the spans of all matchers. They represent the "interface" of the macro.
620536
let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect();
621537

622538
Macro {
623-
hid: def.hir_id,
624539
def_id: self.cx.tcx.hir().local_def_id(def.hir_id).to_def_id(),
625-
attrs: &def.attrs,
626540
name: renamed.unwrap_or(def.ident.name),
627-
span: def.span,
628541
matchers,
629542
imported_from: None,
630543
}

0 commit comments

Comments
 (0)