@@ -1617,9 +1617,10 @@ pub(crate) fn clean_middle_ty<'tcx>(
1617
1617
// HACK: pick the first `did` as the `did` of the trait object. Someone
1618
1618
// might want to implement "native" support for marker-trait-only
1619
1619
// trait objects.
1620
- let mut dids = obj. principal_def_id ( ) . into_iter ( ) . chain ( obj. auto_traits ( ) ) ;
1621
- let did = dids
1622
- . next ( )
1620
+ let mut dids = obj. auto_traits ( ) ;
1621
+ let did = obj
1622
+ . principal_def_id ( )
1623
+ . or_else ( || dids. next ( ) )
1623
1624
. unwrap_or_else ( || panic ! ( "found trait object `{:?}` with no traits?" , this) ) ;
1624
1625
let substs = match obj. principal ( ) {
1625
1626
Some ( principal) => principal. skip_binder ( ) . substs ,
@@ -1630,15 +1631,14 @@ pub(crate) fn clean_middle_ty<'tcx>(
1630
1631
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1631
1632
1632
1633
let lifetime = clean_middle_region ( * reg) ;
1633
- let mut bounds = vec ! [ ] ;
1634
-
1635
- for did in dids {
1636
- let empty = cx. tcx . intern_substs ( & [ ] ) ;
1637
- let path = external_path ( cx, did, false , vec ! [ ] , empty) ;
1638
- inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1639
- let bound = PolyTrait { trait_ : path, generic_params : Vec :: new ( ) } ;
1640
- bounds. push ( bound) ;
1641
- }
1634
+ let mut bounds = dids
1635
+ . map ( |did| {
1636
+ let empty = cx. tcx . intern_substs ( & [ ] ) ;
1637
+ let path = external_path ( cx, did, false , vec ! [ ] , empty) ;
1638
+ inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1639
+ PolyTrait { trait_ : path, generic_params : Vec :: new ( ) }
1640
+ } )
1641
+ . collect :: < Vec < _ > > ( ) ;
1642
1642
1643
1643
let bindings = obj
1644
1644
. projection_bounds ( )
0 commit comments