@@ -1528,7 +1528,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
15281528 ty:: TyTrait ( ref data) => {
15291529 match this. tcx ( ) . lang_items . to_builtin_kind ( obligation. predicate . def_id ( ) ) {
15301530 Some ( bound @ ty:: BoundSend ) | Some ( bound @ ty:: BoundSync ) => {
1531- if data. bounds . builtin_bounds . contains ( & bound) {
1531+ if data. builtin_bounds . contains ( & bound) {
15321532 debug ! ( "assemble_candidates_from_object_ty: matched builtin bound, \
15331533 pushing candidate") ;
15341534 candidates. vec . push ( BuiltinObjectCandidate ) ;
@@ -1538,7 +1538,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
15381538 _ => { }
15391539 }
15401540
1541- data. principal_trait_ref_with_self_ty ( this. tcx ( ) , self_ty)
1541+ data. principal . with_self_ty ( this. tcx ( ) , self_ty)
15421542 }
15431543 ty:: TyInfer ( ty:: TyVar ( _) ) => {
15441544 debug ! ( "assemble_candidates_from_object_ty: ambiguous" ) ;
@@ -1622,7 +1622,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
16221622 // We always upcast when we can because of reason
16231623 // #2 (region bounds).
16241624 data_a. principal . def_id ( ) == data_a. principal . def_id ( ) &&
1625- data_a. bounds . builtin_bounds . is_superset ( & data_b. bounds . builtin_bounds )
1625+ data_a. builtin_bounds . is_superset ( & data_b. builtin_bounds )
16261626 }
16271627
16281628 // T -> Trait.
@@ -2179,10 +2179,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
21792179 match self_ty. sty {
21802180 ty:: TyTrait ( ref data) => {
21812181 // OK to skip the binder, it is reintroduced below
2182- let input_types = data. principal . skip_binder ( ) . substs . types . get_slice ( TypeSpace ) ;
2183- let assoc_types = data. bounds . projection_bounds
2184- . iter ( )
2185- . map ( |pb| pb. skip_binder ( ) . ty ) ;
2182+ let input_types = data. principal . skip_binder ( ) . input_types ( ) ;
2183+ let assoc_types = data. projection_bounds . iter ( )
2184+ . map ( |pb| pb. skip_binder ( ) . ty ) ;
21862185 let all_types: Vec < _ > = input_types. iter ( ) . cloned ( )
21872186 . chain ( assoc_types)
21882187 . collect ( ) ;
@@ -2315,7 +2314,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
23152314 let self_ty = self . infcx . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
23162315 let poly_trait_ref = match self_ty. sty {
23172316 ty:: TyTrait ( ref data) => {
2318- data. principal_trait_ref_with_self_ty ( self . tcx ( ) , self_ty)
2317+ data. principal . with_self_ty ( self . tcx ( ) , self_ty)
23192318 }
23202319 _ => {
23212320 span_bug ! ( obligation. cause. span,
@@ -2487,13 +2486,12 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
24872486 // Trait+Kx+'a -> Trait+Ky+'b (upcasts).
24882487 ( & ty:: TyTrait ( ref data_a) , & ty:: TyTrait ( ref data_b) ) => {
24892488 // See assemble_candidates_for_unsizing for more info.
2490- let bounds = ty:: ExistentialBounds {
2491- region_bound : data_b. bounds . region_bound ,
2492- builtin_bounds : data_b. bounds . builtin_bounds ,
2493- projection_bounds : data_a. bounds . projection_bounds . clone ( ) ,
2494- } ;
2495-
2496- let new_trait = tcx. mk_trait ( data_a. principal . clone ( ) , bounds) ;
2489+ let new_trait = tcx. mk_trait ( ty:: TraitObject {
2490+ principal : data_a. principal ,
2491+ region_bound : data_b. region_bound ,
2492+ builtin_bounds : data_b. builtin_bounds ,
2493+ projection_bounds : data_a. projection_bounds . clone ( ) ,
2494+ } ) ;
24972495 let origin = TypeOrigin :: Misc ( obligation. cause . span ) ;
24982496 let InferOk { obligations, .. } =
24992497 self . infcx . sub_types ( false , origin, new_trait, target)
@@ -2504,21 +2502,21 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25042502 let cause = ObligationCause :: new ( obligation. cause . span ,
25052503 obligation. cause . body_id ,
25062504 ObjectCastObligation ( target) ) ;
2507- let outlives = ty:: OutlivesPredicate ( data_a. bounds . region_bound ,
2508- data_b. bounds . region_bound ) ;
2505+ let outlives = ty:: OutlivesPredicate ( data_a. region_bound ,
2506+ data_b. region_bound ) ;
25092507 nested. push ( Obligation :: with_depth ( cause,
25102508 obligation. recursion_depth + 1 ,
25112509 ty:: Binder ( outlives) . to_predicate ( ) ) ) ;
25122510 }
25132511
25142512 // T -> Trait.
25152513 ( _, & ty:: TyTrait ( ref data) ) => {
2516- let mut object_dids = Some ( data. principal_def_id ( ) ) . into_iter ( ) ;
2514+ let mut object_dids = Some ( data. principal . def_id ( ) ) . into_iter ( ) ;
25172515 // FIXME(#33243)
2518- // data.bounds. builtin_bounds.iter().flat_map(|bound| {
2516+ // data.builtin_bounds.iter().flat_map(|bound| {
25192517// tcx.lang_items.from_builtin_kind(bound).ok()
25202518// })
2521- // .chain(Some(data.principal_def_id ()));
2519+ // .chain(Some(data.principal.def_id ()));
25222520 if let Some ( did) = object_dids. find ( |did| {
25232521 !tcx. is_object_safe ( * did)
25242522 } ) {
@@ -2535,10 +2533,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25352533 } ;
25362534
25372535 // Create the obligation for casting from T to Trait.
2538- push ( data. principal_trait_ref_with_self_ty ( tcx, source) . to_predicate ( ) ) ;
2536+ push ( data. principal . with_self_ty ( tcx, source) . to_predicate ( ) ) ;
25392537
25402538 // We can only make objects from sized types.
2541- let mut builtin_bounds = data. bounds . builtin_bounds ;
2539+ let mut builtin_bounds = data. builtin_bounds ;
25422540 builtin_bounds. insert ( ty:: BoundSized ) ;
25432541
25442542 // Create additional obligations for all the various builtin
@@ -2554,14 +2552,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
25542552 }
25552553
25562554 // Create obligations for the projection predicates.
2557- for bound in data. projection_bounds_with_self_ty ( tcx , source ) {
2558- push ( bound. to_predicate ( ) ) ;
2555+ for bound in & data. projection_bounds {
2556+ push ( bound. with_self_ty ( tcx , source ) . to_predicate ( ) ) ;
25592557 }
25602558
25612559 // If the type is `Foo+'a`, ensures that the type
25622560 // being cast to `Foo+'a` outlives `'a`:
2563- let outlives = ty:: OutlivesPredicate ( source,
2564- data. bounds . region_bound ) ;
2561+ let outlives = ty:: OutlivesPredicate ( source, data. region_bound ) ;
25652562 push ( ty:: Binder ( outlives) . to_predicate ( ) ) ;
25662563 }
25672564
0 commit comments