@@ -187,16 +187,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
187
187
ret
188
188
}
189
189
190
- #[ inline]
191
- fn add_to_current_mod (
192
- & mut self ,
193
- item : & ' tcx hir:: Item < ' _ > ,
194
- renamed : Option < Symbol > ,
195
- parent_id : Option < hir:: HirId > ,
196
- ) {
197
- self . modules . last_mut ( ) . unwrap ( ) . items . push ( ( item, renamed, parent_id) )
198
- }
199
-
200
190
fn visit_item_inner (
201
191
& mut self ,
202
192
item : & ' tcx hir:: Item < ' _ > ,
@@ -257,7 +247,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
257
247
}
258
248
}
259
249
260
- self . add_to_current_mod ( item, renamed, parent_id) ;
250
+ self . modules . last_mut ( ) . unwrap ( ) . items . push ( ( item, renamed, parent_id) ) ;
261
251
}
262
252
}
263
253
hir:: ItemKind :: Macro ( ref macro_def, _) => {
@@ -277,7 +267,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
277
267
let nonexported = !self . cx . tcx . has_attr ( def_id, sym:: macro_export) ;
278
268
279
269
if is_macro_2_0 || nonexported || self . inlining {
280
- self . add_to_current_mod ( item, renamed, None ) ;
270
+ self . modules . last_mut ( ) . unwrap ( ) . items . push ( ( item, renamed, None ) ) ;
281
271
}
282
272
}
283
273
hir:: ItemKind :: Mod ( ref m) => {
@@ -293,20 +283,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
293
283
| hir:: ItemKind :: Static ( ..)
294
284
| hir:: ItemKind :: Trait ( ..)
295
285
| hir:: ItemKind :: TraitAlias ( ..) => {
296
- self . add_to_current_mod ( item, renamed, parent_id) ;
286
+ self . modules . last_mut ( ) . unwrap ( ) . items . push ( ( item, renamed, parent_id) )
297
287
}
298
288
hir:: ItemKind :: Const ( ..) => {
299
289
// Underscore constants do not correspond to a nameable item and
300
290
// so are never useful in documentation.
301
291
if name != kw:: Underscore {
302
- self . add_to_current_mod ( item, renamed, parent_id) ;
292
+ self . modules . last_mut ( ) . unwrap ( ) . items . push ( ( item, renamed, parent_id) ) ;
303
293
}
304
294
}
305
295
hir:: ItemKind :: Impl ( impl_) => {
306
296
// Don't duplicate impls when inlining or if it's implementing a trait, we'll pick
307
297
// them up regardless of where they're located.
308
298
if !self . inlining && impl_. of_trait . is_none ( ) {
309
- self . add_to_current_mod ( item, None , None ) ;
299
+ self . modules . last_mut ( ) . unwrap ( ) . items . push ( ( item, None , None ) ) ;
310
300
}
311
301
}
312
302
}
@@ -343,13 +333,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
343
333
// macro in the same module.
344
334
let mut inserted = FxHashSet :: default ( ) ;
345
335
for export in self . cx . tcx . module_reexports ( CRATE_DEF_ID ) . unwrap_or ( & [ ] ) {
346
- if let Res :: Def ( DefKind :: Macro ( _) , def_id) = export. res &&
347
- let Some ( local_def_id) = def_id. as_local ( ) &&
348
- self . cx . tcx . has_attr ( def_id, sym:: macro_export) &&
349
- inserted. insert ( def_id)
350
- {
351
- let item = self . cx . tcx . hir ( ) . expect_item ( local_def_id) ;
352
- top_level_module. items . push ( ( item, None , None ) ) ;
336
+ if let Res :: Def ( DefKind :: Macro ( _) , def_id) = export. res {
337
+ if let Some ( local_def_id) = def_id. as_local ( ) {
338
+ if self . cx . tcx . has_attr ( def_id, sym:: macro_export) {
339
+ if inserted. insert ( def_id) {
340
+ let item = self . cx . tcx . hir ( ) . expect_item ( local_def_id) ;
341
+ top_level_module. items . push ( ( item, None , None ) ) ;
342
+ }
343
+ }
344
+ }
353
345
}
354
346
}
355
347
0 commit comments