@@ -485,27 +485,37 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
485485 mut self ,
486486 predicates : & ' tcx ty:: List < ty:: Binder < ' tcx , ty:: ExistentialPredicate < ' tcx > > > ,
487487 ) -> Result < Self :: DynExistential , Self :: Error > {
488- for predicate in predicates {
489- self = self . in_binder ( & predicate, |mut cx, predicate| {
490- match predicate {
491- ty:: ExistentialPredicate :: Trait ( trait_ref) => {
488+ let mut predicate_iter = predicates. iter ( ) . peekable ( ) ;
489+ while let Some ( predicate) = predicate_iter. next ( ) {
490+ match predicate. as_ref ( ) . skip_binder ( ) {
491+ ty:: ExistentialPredicate :: Trait ( trait_ref) => {
492+ self = self . in_binder ( & predicate, |mut cx, _predicate| {
492493 // Use a type that can't appear in defaults of type parameters.
493494 let dummy_self = cx. tcx . mk_ty_infer ( ty:: FreshTy ( 0 ) ) ;
494495 let trait_ref = trait_ref. with_self_ty ( cx. tcx , dummy_self) ;
495496 cx = cx. print_def_path ( trait_ref. def_id , trait_ref. substs ) ?;
496- }
497- ty:: ExistentialPredicate :: Projection ( projection) => {
498- let name = cx. tcx . associated_item ( projection. item_def_id ) . ident ;
499- cx. push ( "p" ) ;
500- cx. push_ident ( & name. as_str ( ) ) ;
501- cx = projection. ty . print ( cx) ?;
502- }
503- ty:: ExistentialPredicate :: AutoTrait ( def_id) => {
504- cx = cx. print_def_path ( * def_id, & [ ] ) ?;
505- }
497+ while let Some ( projection_pred) = predicate_iter. next_if ( |p| {
498+ matches ! ( p. skip_binder( ) , ty:: ExistentialPredicate :: Projection ( _) )
499+ } ) {
500+ let projection = match projection_pred. skip_binder ( ) {
501+ ty:: ExistentialPredicate :: Projection ( projection) => projection,
502+ _ => unreachable ! ( ) ,
503+ } ;
504+ let name = cx. tcx . associated_item ( projection. item_def_id ) . ident ;
505+ cx. push ( "p" ) ;
506+ cx. push_ident ( & name. as_str ( ) ) ;
507+ cx = projection. ty . print ( cx) ?;
508+ }
509+ Ok ( cx)
510+ } ) ?;
506511 }
507- Ok ( cx)
508- } ) ?;
512+ ty:: ExistentialPredicate :: Projection ( _) => {
513+ unreachable ! ( "handled in trait predicate arm" )
514+ }
515+ ty:: ExistentialPredicate :: AutoTrait ( def_id) => {
516+ self = self . print_def_path ( * def_id, & [ ] ) ?;
517+ }
518+ }
509519 }
510520 self . push ( "E" ) ;
511521 Ok ( self )
0 commit comments