@@ -187,8 +187,20 @@ impl Cache {
187
187
188
188
/// `external_trats` / `cache.traits` is modified in various passes.
189
189
/// Run this separate from the main `populate` call, since `impls` isn't used until later in the HTML formatter.
190
- crate fn populate_impls ( & mut self , krate : & clean:: Crate ) {
190
+ crate fn populate_impls ( & mut self , krate : clean:: Crate ) -> clean :: Crate {
191
191
self . traits = krate. external_traits . take ( ) ;
192
+ ImplRemover . fold_crate ( krate)
193
+ }
194
+ }
195
+
196
+ struct ImplRemover ;
197
+ impl DocFolder for ImplRemover {
198
+ fn fold_item ( & mut self , item : clean:: Item ) -> Option < clean:: Item > {
199
+ let item = self . fold_item_recur ( item) ;
200
+ match * item. kind {
201
+ clean:: ItemKind :: ImplItem ( _) => None ,
202
+ _ => Some ( item) ,
203
+ }
192
204
}
193
205
}
194
206
@@ -438,7 +450,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
438
450
// Once we've recursively found all the generics, hoard off all the
439
451
// implementations elsewhere.
440
452
let item = self . fold_item_recur ( item) ;
441
- let ret = if let clean:: Item { kind : box clean:: ImplItem ( ref i) , .. } = item {
453
+ if let clean:: Item { kind : box clean:: ImplItem ( ref i) , .. } = item {
442
454
// Figure out the id of this impl. This may map to a
443
455
// primitive rather than always to a struct/enum.
444
456
// Note: matching twice to restrict the lifetime of the `i` borrow.
@@ -470,7 +482,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
470
482
}
471
483
}
472
484
}
473
- let impl_item = Impl { impl_item : item } ;
485
+ let impl_item = Impl { impl_item : item. clone ( ) } ;
474
486
if impl_item. trait_did ( ) . map_or ( true , |d| self . cache . traits . contains_key ( & d) ) {
475
487
for did in dids {
476
488
self . cache . impls . entry ( did) . or_insert_with ( Vec :: new) . push ( impl_item. clone ( ) ) ;
@@ -479,18 +491,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
479
491
let trait_did = impl_item. trait_did ( ) . expect ( "no trait did" ) ;
480
492
self . cache . orphan_trait_impls . push ( ( trait_did, dids, impl_item. clone ( ) ) ) ;
481
493
}
482
- // TODO: stripping this from `Module` seems ... not great
483
- // None
484
- let item = impl_item. impl_item ;
485
- if item. def_id . is_local ( ) {
486
- debug ! ( "propagating impl {:?}" , item) ;
487
- Some ( item)
488
- } else {
489
- None
490
- }
491
- } else {
492
- Some ( item)
493
- } ;
494
+ }
494
495
495
496
if pushed {
496
497
self . cache . stack . pop ( ) . expect ( "stack already empty" ) ;
@@ -500,6 +501,6 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
500
501
}
501
502
self . cache . stripped_mod = orig_stripped_mod;
502
503
self . cache . parent_is_trait_impl = orig_parent_is_trait_impl;
503
- ret
504
+ Some ( item )
504
505
}
505
506
}
0 commit comments