@@ -2088,10 +2088,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2088
2088
return ;
2089
2089
}
2090
2090
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)
2095
2092
}
2096
2093
ty:: Infer ( ty:: TyVar ( _) ) => {
2097
2094
debug ! ( "assemble_candidates_from_object_ty: ambiguous" ) ;
@@ -2183,15 +2180,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2183
2180
//
2184
2181
// We always upcast when we can because of reason
2185
2182
// #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) )
2195
2187
}
2196
2188
2197
2189
// T -> Trait.
@@ -2981,7 +2973,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2981
2973
. shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
2982
2974
let poly_trait_ref = match self_ty. sty {
2983
2975
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)
2985
2977
}
2986
2978
_ => span_bug ! ( obligation. cause. span, "object candidate with non-object" ) ,
2987
2979
} ;
@@ -3244,10 +3236,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
3244
3236
( & ty:: Dynamic ( ref data_a, r_a) , & ty:: Dynamic ( ref data_b, r_b) ) => {
3245
3237
// See assemble_candidates_for_unsizing for more info.
3246
3238
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 ( ) ) )
3251
3240
. chain (
3252
3241
data_a
3253
3242
. projection_bounds ( )
@@ -3285,7 +3274,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
3285
3274
// T -> Trait.
3286
3275
( _, & ty:: Dynamic ( ref data, r) ) => {
3287
3276
let mut object_dids = data. auto_traits ( )
3288
- . chain ( data. principal ( ) . map ( |p| p . def_id ( ) ) ) ;
3277
+ . chain ( iter :: once ( data. principal ( ) . def_id ( ) ) ) ;
3289
3278
if let Some ( did) = object_dids. find ( |did| !tcx. is_object_safe ( * did) ) {
3290
3279
return Err ( TraitNotObjectSafe ( did) ) ;
3291
3280
}
0 commit comments