@@ -798,10 +798,10 @@ fn clean_ty_generics<'tcx>(
798798 let where_predicates = preds
799799 . predicates
800800 . iter ( )
801- . flat_map ( |( p , _) | {
801+ . flat_map ( |( pred , _) | {
802802 let mut projection = None ;
803803 let param_idx = ( || {
804- let bound_p = p . kind ( ) ;
804+ let bound_p = pred . kind ( ) ;
805805 match bound_p. skip_binder ( ) {
806806 ty:: ClauseKind :: Trait ( pred) => {
807807 if let ty:: Param ( param) = pred. self_ty ( ) . kind ( ) {
@@ -826,33 +826,27 @@ fn clean_ty_generics<'tcx>(
826826 } ) ( ) ;
827827
828828 if let Some ( param_idx) = param_idx
829- && let Some ( b ) = impl_trait. get_mut ( & param_idx. into ( ) )
829+ && let Some ( bounds ) = impl_trait. get_mut ( & param_idx. into ( ) )
830830 {
831- let p : WherePredicate = clean_predicate ( * p , cx) ?;
831+ let pred = clean_predicate ( * pred , cx) ?;
832832
833- b . extend (
834- p . get_bounds ( )
833+ bounds . extend (
834+ pred . get_bounds ( )
835835 . into_iter ( )
836836 . flatten ( )
837837 . cloned ( )
838838 . filter ( |b| !b. is_sized_bound ( cx) ) ,
839839 ) ;
840840
841- let proj = projection. map ( |p| {
842- (
843- clean_projection ( p. map_bound ( |p| p. projection_ty ) , cx, None ) ,
844- p. map_bound ( |p| p. term ) ,
845- )
846- } ) ;
847- if let Some ( ( ( _, trait_did, name) , rhs) ) = proj
848- . as_ref ( )
849- . and_then ( |( lhs, rhs) : & ( Type , _ ) | Some ( ( lhs. projection ( ) ?, rhs) ) )
841+ if let Some ( proj) = projection
842+ && let lhs = clean_projection ( proj. map_bound ( |p| p. projection_ty ) , cx, None )
843+ && let Some ( ( _, trait_did, name) ) = lhs. projection ( )
850844 {
851845 impl_trait_proj. entry ( param_idx) . or_default ( ) . push ( (
852846 trait_did,
853847 name,
854- * rhs ,
855- p . get_bound_params ( )
848+ proj . map_bound ( |p| p . term ) ,
849+ pred . get_bound_params ( )
856850 . into_iter ( )
857851 . flatten ( )
858852 . cloned ( )
@@ -863,7 +857,7 @@ fn clean_ty_generics<'tcx>(
863857 return None ;
864858 }
865859
866- Some ( p )
860+ Some ( pred )
867861 } )
868862 . collect :: < Vec < _ > > ( ) ;
869863
@@ -891,7 +885,7 @@ fn clean_ty_generics<'tcx>(
891885 // implicit `Sized` bound unless removed with `?Sized`.
892886 // However, in the list of where-predicates below, `Sized` appears like a
893887 // normal bound: It's either present (the type is sized) or
894- // absent (the type is unsized) but never *maybe* (i.e. `?Sized`).
888+ // absent (the type might be unsized) but never *maybe* (i.e. `?Sized`).
895889 //
896890 // This is unsuitable for rendering.
897891 // Thus, as a first step remove all `Sized` bounds that should be implicit.
@@ -902,8 +896,8 @@ fn clean_ty_generics<'tcx>(
902896 let mut sized_params = FxHashSet :: default ( ) ;
903897 where_predicates. retain ( |pred| {
904898 if let WherePredicate :: BoundPredicate { ty : Generic ( g) , bounds, .. } = pred
905- && * g != kw:: SelfUpper
906- && bounds. iter ( ) . any ( |b| b. is_sized_bound ( cx) )
899+ && * g != kw:: SelfUpper
900+ && bounds. iter ( ) . any ( |b| b. is_sized_bound ( cx) )
907901 {
908902 sized_params. insert ( * g) ;
909903 false
0 commit comments