@@ -480,18 +480,28 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
480480 let projected_ty = curr_projected_ty. projection_ty_core (
481481 tcx,
482482 proj,
483- |ty| self . normalize ( ty, locations) ,
484- |ty, variant_index, field, ( ) | PlaceTy :: field_ty ( tcx, ty, variant_index, field) ,
483+ |ty| self . normalize ( ty:: Unnormalized :: new_wip ( ty) , locations) ,
484+ |ty, variant_index, field, ( ) | {
485+ PlaceTy :: field_ty ( tcx, ty, variant_index, field) . skip_norm_wip ( )
486+ } ,
485487 |_| unreachable ! ( ) ,
486488 ) ;
487489 curr_projected_ty = projected_ty;
488490 }
489491 trace ! ( ?curr_projected_ty) ;
490492
491- // Need to renormalize `a` as typecheck may have failed to normalize
492- // higher-ranked aliases if normalization was ambiguous due to inference.
493- let a = self . normalize ( a, locations) ;
494- let ty = self . normalize ( curr_projected_ty. ty , locations) ;
493+ // Need to renormalize `a` in the old solver as typecheck may have failed
494+ // to normalize higher-ranked aliases if normalization was ambiguous due
495+ // to inference.
496+ //
497+ // We properly normalize higher-ranked aliases during writeback with the
498+ // new solver, so this is no longer necessary.
499+ let mut a = a;
500+ let mut ty = curr_projected_ty. ty ;
501+ if !self . infcx . next_trait_solver ( ) {
502+ a = self . normalize ( ty:: Unnormalized :: new_wip ( a) , locations) ;
503+ ty = self . normalize ( ty:: Unnormalized :: new_wip ( ty) , locations) ;
504+ }
495505 self . relate_types ( ty, v. xform ( ty:: Contravariant ) , a, locations, category) ?;
496506
497507 Ok ( ( ) )
@@ -639,11 +649,11 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
639649
640650 let place_ty = place. ty ( self . body , tcx) . ty ;
641651 debug ! ( ?place_ty) ;
642- let place_ty = self . normalize ( place_ty, location) ;
652+ let place_ty = self . normalize ( ty :: Unnormalized :: new_wip ( place_ty) , location) ;
643653 debug ! ( "place_ty normalized: {:?}" , place_ty) ;
644654 let rv_ty = rv. ty ( self . body , tcx) ;
645655 debug ! ( ?rv_ty) ;
646- let rv_ty = self . normalize ( rv_ty, location) ;
656+ let rv_ty = self . normalize ( ty :: Unnormalized :: new_wip ( rv_ty) , location) ;
647657 debug ! ( "normalized rv_ty: {:?}" , rv_ty) ;
648658 if let Err ( terr) =
649659 self . sub_types ( rv_ty, place_ty, location. to_locations ( ) , category)
@@ -1082,7 +1092,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10821092 } ,
10831093 ) ;
10841094
1085- let src_ty = self . normalize ( src_ty, location) ;
1095+ let src_ty =
1096+ self . normalize ( ty:: Unnormalized :: new_wip ( src_ty) , location) ;
10861097 if let Err ( terr) = self . sub_types (
10871098 src_ty,
10881099 * ty,
@@ -1124,7 +1135,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
11241135 // function definition. When we extract the
11251136 // signature, it comes from the `fn_sig` query,
11261137 // and hence may contain unnormalized results.
1127- let src_ty = self . normalize ( src_ty, location) ;
1138+ let src_ty = self . normalize ( ty :: Unnormalized :: new_wip ( src_ty) , location) ;
11281139 if let Err ( terr) = self . sub_types (
11291140 src_ty,
11301141 * ty,
@@ -1190,7 +1201,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
11901201 // function definition. When we extract the
11911202 // signature, it comes from the `fn_sig` query,
11921203 // and hence may contain unnormalized results.
1193- let fn_sig = self . normalize ( fn_sig, location) ;
1204+ let fn_sig = self . normalize ( ty :: Unnormalized :: new_wip ( fn_sig) , location) ;
11941205
11951206 let ty_fn_ptr_from = tcx. safe_to_unsafe_fn_ty ( fn_sig) ;
11961207
@@ -1786,8 +1797,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
17861797 ) ;
17871798 }
17881799 } else if let Some ( static_def_id) = constant. check_static_ptr ( tcx) {
1789- let unnormalized_ty =
1790- tcx. type_of ( static_def_id) . instantiate_identity ( ) . skip_norm_wip ( ) ;
1800+ let unnormalized_ty = tcx. type_of ( static_def_id) . instantiate_identity ( ) ;
17911801 let normalized_ty = self . normalize ( unnormalized_ty, locations) ;
17921802 let literal_ty = constant. const_ . ty ( ) . builtin_deref ( true ) . unwrap ( ) ;
17931803
@@ -1876,7 +1886,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
18761886 | ProjectionElem :: Subslice { .. }
18771887 | ProjectionElem :: Downcast ( ..) => { }
18781888 ProjectionElem :: Field ( field, fty) => {
1879- let fty = self . normalize ( fty, location) ;
1889+ let fty = self . normalize ( ty :: Unnormalized :: new_wip ( fty) , location) ;
18801890 let ty = PlaceTy :: field_ty ( tcx, base_ty. ty , base_ty. variant_index , field) ;
18811891 let ty = self . normalize ( ty, location) ;
18821892 debug ! ( ?fty, ?ty) ;
@@ -1892,7 +1902,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
18921902 }
18931903 }
18941904 ProjectionElem :: OpaqueCast ( ty) => {
1895- let ty = self . normalize ( ty, location) ;
1905+ let ty = self . normalize ( ty:: Unnormalized :: new_wip ( ty ) , location) ;
18961906 self . relate_types (
18971907 ty,
18981908 context. ambient_variance ( ) ,
@@ -1945,7 +1955,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19451955 }
19461956 } else {
19471957 let dest_ty = destination. ty ( self . body , tcx) . ty ;
1948- let dest_ty = self . normalize ( dest_ty, term_location) ;
1958+ let dest_ty = self . normalize ( ty :: Unnormalized :: new_wip ( dest_ty) , term_location) ;
19491959 let category = match destination. as_local ( ) {
19501960 Some ( RETURN_PLACE ) => {
19511961 if let DefiningTy :: Const ( def_id, _) | DefiningTy :: InlineConst ( def_id, _) =
@@ -2030,7 +2040,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20302040 for ( n, ( fn_arg, op_arg) ) in iter:: zip ( sig. inputs ( ) , args) . enumerate ( ) {
20312041 let op_arg_ty = op_arg. node . ty ( self . body , self . tcx ( ) ) ;
20322042
2033- let op_arg_ty = self . normalize ( op_arg_ty, term_location) ;
2043+ let op_arg_ty = self . normalize ( ty :: Unnormalized :: new_wip ( op_arg_ty) , term_location) ;
20342044 let category = if call_source. from_hir_call ( ) {
20352045 ConstraintCategory :: CallArgument ( Some (
20362046 self . infcx . tcx . erase_and_anonymize_regions ( func_ty) ,
@@ -2302,7 +2312,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
23022312 }
23032313 } ;
23042314 let operand_ty = operand. ty ( self . body , tcx) ;
2305- let operand_ty = self . normalize ( operand_ty, location) ;
2315+ let operand_ty = self . normalize ( ty :: Unnormalized :: new_wip ( operand_ty) , location) ;
23062316
23072317 if let Err ( terr) = self . sub_types (
23082318 operand_ty,
@@ -2513,8 +2523,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25132523 else {
25142524 continue ;
25152525 } ;
2516- let dest_ty = dest_field. ty ( tcx, dest_args) ;
2517- let borrowed_ty = borrowed_field. ty ( tcx, borrowed_args) ;
2526+ let dest_ty = dest_field. ty ( tcx, dest_args) . skip_norm_wip ( ) ;
2527+ let borrowed_ty = borrowed_field. ty ( tcx, borrowed_args) . skip_norm_wip ( ) ;
25182528 if let (
25192529 ty:: Ref ( borrow_region, _, Mutability :: Mut ) ,
25202530 ty:: Ref ( ref_region, _, Mutability :: Not ) ,
0 commit comments