@@ -2088,10 +2088,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
20882088 return ;
20892089 }
20902090
2091- match data. principal ( ) {
2092- Some ( p) => p. with_self_ty ( this. tcx ( ) , self_ty) ,
2093- None => return ,
2094- }
2091+ data. principal ( ) . with_self_ty ( this. tcx ( ) , self_ty)
20952092 }
20962093 ty:: Infer ( ty:: TyVar ( _) ) => {
20972094 debug ! ( "assemble_candidates_from_object_ty: ambiguous" ) ;
@@ -2183,15 +2180,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
21832180 //
21842181 // We always upcast when we can because of reason
21852182 // #2 (region bounds).
2186- match ( data_a. principal ( ) , data_b. principal ( ) ) {
2187- ( Some ( a) , Some ( b) ) => {
2188- a. def_id ( ) == b. def_id ( )
2189- && data_b. auto_traits ( )
2190- // All of a's auto traits need to be in b's auto traits.
2191- . all ( |b| data_a. auto_traits ( ) . any ( |a| a == b) )
2192- }
2193- _ => false ,
2194- }
2183+ data_a. principal ( ) . def_id ( ) == data_b. principal ( ) . def_id ( )
2184+ && data_b. auto_traits ( )
2185+ // All of a's auto traits need to be in b's auto traits.
2186+ . all ( |b| data_a. auto_traits ( ) . any ( |a| a == b) )
21952187 }
21962188
21972189 // T -> Trait.
@@ -2981,7 +2973,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
29812973 . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
29822974 let poly_trait_ref = match self_ty. sty {
29832975 ty:: Dynamic ( ref data, ..) => {
2984- data. principal ( ) . unwrap ( ) . with_self_ty ( self . tcx ( ) , self_ty)
2976+ data. principal ( ) . with_self_ty ( self . tcx ( ) , self_ty)
29852977 }
29862978 _ => span_bug ! ( obligation. cause. span, "object candidate with non-object" ) ,
29872979 } ;
@@ -3244,10 +3236,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
32443236 ( & ty:: Dynamic ( ref data_a, r_a) , & ty:: Dynamic ( ref data_b, r_b) ) => {
32453237 // See assemble_candidates_for_unsizing for more info.
32463238 let existential_predicates = data_a. map_bound ( |data_a| {
3247- let principal = data_a. principal ( ) ;
3248- let iter = principal
3249- . into_iter ( )
3250- . map ( ty:: ExistentialPredicate :: Trait )
3239+ let iter = iter:: once ( ty:: ExistentialPredicate :: Trait ( data_a. principal ( ) ) )
32513240 . chain (
32523241 data_a
32533242 . projection_bounds ( )
@@ -3285,7 +3274,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
32853274 // T -> Trait.
32863275 ( _, & ty:: Dynamic ( ref data, r) ) => {
32873276 let mut object_dids = data. auto_traits ( )
3288- . chain ( data. principal ( ) . map ( |p| p . def_id ( ) ) ) ;
3277+ . chain ( iter :: once ( data. principal ( ) . def_id ( ) ) ) ;
32893278 if let Some ( did) = object_dids. find ( |did| !tcx. is_object_safe ( * did) ) {
32903279 return Err ( TraitNotObjectSafe ( did) ) ;
32913280 }
0 commit comments