@@ -187,8 +187,20 @@ impl Cache {
187187
188188 /// `external_trats` / `cache.traits` is modified in various passes.
189189 /// 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 {
191191 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+ }
192204 }
193205}
194206
@@ -438,7 +450,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
438450 // Once we've recursively found all the generics, hoard off all the
439451 // implementations elsewhere.
440452 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 {
442454 // Figure out the id of this impl. This may map to a
443455 // primitive rather than always to a struct/enum.
444456 // Note: matching twice to restrict the lifetime of the `i` borrow.
@@ -470,7 +482,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
470482 }
471483 }
472484 }
473- let impl_item = Impl { impl_item : item } ;
485+ let impl_item = Impl { impl_item : item. clone ( ) } ;
474486 if impl_item. trait_did ( ) . map_or ( true , |d| self . cache . traits . contains_key ( & d) ) {
475487 for did in dids {
476488 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> {
479491 let trait_did = impl_item. trait_did ( ) . expect ( "no trait did" ) ;
480492 self . cache . orphan_trait_impls . push ( ( trait_did, dids, impl_item. clone ( ) ) ) ;
481493 }
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+ }
494495
495496 if pushed {
496497 self . cache . stack . pop ( ) . expect ( "stack already empty" ) ;
@@ -500,6 +501,6 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
500501 }
501502 self . cache . stripped_mod = orig_stripped_mod;
502503 self . cache . parent_is_trait_impl = orig_parent_is_trait_impl;
503- ret
504+ Some ( item )
504505 }
505506}
0 commit comments