@@ -29,7 +29,7 @@ use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion};
2929use rustc_middle:: ty:: layout:: ValidityRequirement ;
3030use rustc_middle:: ty:: {
3131 self , GenericArgs , GenericParamDefKind , Instance , InstanceKind , Ty , TyCtxt , TypeFoldable ,
32- TypeVisitableExt , VtblEntry ,
32+ TypeVisitableExt , Unnormalized , VtblEntry ,
3333} ;
3434use rustc_session:: config:: { DebugInfo , EntryFnType } ;
3535use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span , Spanned , dummy_spanned, respan} ;
@@ -960,10 +960,14 @@ pub fn find_tails_for_unsizing<'tcx>(
960960 } ;
961961 let coerce_field = & source_adt_def. non_enum_variant ( ) . fields [ coerce_index] ;
962962 // We're getting a possibly unnormalized type, so normalize it.
963- let source_field =
964- tcx. normalize_erasing_regions ( typing_env, coerce_field. ty ( * tcx, source_args) ) ;
965- let target_field =
966- tcx. normalize_erasing_regions ( typing_env, coerce_field. ty ( * tcx, target_args) ) ;
963+ let source_field = tcx. normalize_erasing_regions (
964+ typing_env,
965+ Unnormalized :: new_wip ( coerce_field. ty ( * tcx, source_args) ) ,
966+ ) ;
967+ let target_field = tcx. normalize_erasing_regions (
968+ typing_env,
969+ Unnormalized :: new_wip ( coerce_field. ty ( * tcx, target_args) ) ,
970+ ) ;
967971 find_tails_for_unsizing ( tcx, typing_env, source_field, target_field)
968972 }
969973 _ => bug ! (
@@ -1320,7 +1324,8 @@ impl<'v> RootCollector<'_, 'v> {
13201324 let ty = self
13211325 . tcx
13221326 . type_of ( id. owner_id . to_def_id ( ) )
1323- . instantiate ( self . tcx , id_args) ;
1327+ . instantiate ( self . tcx , id_args)
1328+ . skip_norm_wip ( ) ;
13241329 assert ! ( !ty. has_non_region_param( ) ) ;
13251330 visit_drop_use ( self . tcx , ty, true , DUMMY_SP , self . output ) ;
13261331 }
@@ -1379,25 +1384,36 @@ impl<'v> RootCollector<'_, 'v> {
13791384 match self . tcx . def_kind ( def_id) {
13801385 DefKind :: Closure => {
13811386 // for 'pub async fn foo(..)' also trying to monomorphize foo::{closure}
1382- let is_pub_fn_coroutine =
1383- match * self . tcx . type_of ( def_id) . instantiate_identity ( ) . kind ( ) {
1384- ty:: Coroutine ( cor_id, _args) => {
1385- let tcx = self . tcx ;
1386- let parent_id = tcx. parent ( cor_id) ;
1387- tcx. def_kind ( parent_id) == DefKind :: Fn
1388- && tcx. asyncness ( parent_id) . is_async ( )
1389- && tcx. visibility ( parent_id) . is_public ( )
1390- }
1391- ty:: Closure ( ..) | ty:: CoroutineClosure ( ..) => false ,
1392- _ => unreachable ! ( ) ,
1393- } ;
1387+ let is_pub_fn_coroutine = match * self
1388+ . tcx
1389+ . type_of ( def_id)
1390+ . instantiate_identity ( )
1391+ . skip_norm_wip ( )
1392+ . kind ( )
1393+ {
1394+ ty:: Coroutine ( cor_id, _args) => {
1395+ let tcx = self . tcx ;
1396+ let parent_id = tcx. parent ( cor_id) ;
1397+ tcx. def_kind ( parent_id) == DefKind :: Fn
1398+ && tcx. asyncness ( parent_id) . is_async ( )
1399+ && tcx. visibility ( parent_id) . is_public ( )
1400+ }
1401+ ty:: Closure ( ..) | ty:: CoroutineClosure ( ..) => false ,
1402+ _ => unreachable ! ( ) ,
1403+ } ;
13941404 if ( self . strategy == MonoItemCollectionStrategy :: Eager || is_pub_fn_coroutine)
13951405 && !self
13961406 . tcx
13971407 . generics_of ( self . tcx . typeck_root_def_id ( def_id. to_def_id ( ) ) )
13981408 . requires_monomorphization ( self . tcx )
13991409 {
1400- let instance = match * self . tcx . type_of ( def_id) . instantiate_identity ( ) . kind ( ) {
1410+ let instance = match * self
1411+ . tcx
1412+ . type_of ( def_id)
1413+ . instantiate_identity ( )
1414+ . skip_norm_wip ( )
1415+ . kind ( )
1416+ {
14011417 ty:: Closure ( def_id, args)
14021418 | ty:: Coroutine ( def_id, args)
14031419 | ty:: CoroutineClosure ( def_id, args) => {
@@ -1407,7 +1423,7 @@ impl<'v> RootCollector<'_, 'v> {
14071423 } ;
14081424 let Ok ( instance) = self . tcx . try_normalize_erasing_regions (
14091425 ty:: TypingEnv :: fully_monomorphized ( ) ,
1410- instance,
1426+ Unnormalized :: new_wip ( instance) ,
14111427 ) else {
14121428 // Don't ICE on an impossible-to-normalize closure.
14131429 return ;
@@ -1489,7 +1505,7 @@ impl<'v> RootCollector<'_, 'v> {
14891505 // listing.
14901506 let main_ret_ty = self . tcx . normalize_erasing_regions (
14911507 ty:: TypingEnv :: fully_monomorphized ( ) ,
1492- main_ret_ty. no_bound_vars ( ) . unwrap ( ) ,
1508+ Unnormalized :: new_wip ( main_ret_ty. no_bound_vars ( ) . unwrap ( ) ) ,
14931509 ) ;
14941510
14951511 let start_instance = Instance :: expect_resolve (
@@ -1538,7 +1554,7 @@ fn create_mono_items_for_default_impls<'tcx>(
15381554 }
15391555 } ;
15401556 let impl_args = GenericArgs :: for_item ( tcx, item. owner_id . to_def_id ( ) , only_region_params) ;
1541- let trait_ref = impl_. trait_ref . instantiate ( tcx, impl_args) ;
1557+ let trait_ref = impl_. trait_ref . instantiate ( tcx, impl_args) . skip_norm_wip ( ) ;
15421558
15431559 // Unlike 'lazy' monomorphization that begins by collecting items transitively
15441560 // called by `main` or other global items, when eagerly monomorphizing impl
@@ -1554,7 +1570,7 @@ fn create_mono_items_for_default_impls<'tcx>(
15541570 }
15551571
15561572 let typing_env = ty:: TypingEnv :: fully_monomorphized ( ) ;
1557- let trait_ref = tcx. normalize_erasing_regions ( typing_env, trait_ref) ;
1573+ let trait_ref = tcx. normalize_erasing_regions ( typing_env, Unnormalized :: new_wip ( trait_ref) ) ;
15581574 let overridden_methods = tcx. impl_item_implementor_ids ( item. owner_id ) ;
15591575 for method in tcx. provided_trait_methods ( trait_ref. def_id ) {
15601576 if overridden_methods. contains_key ( & method. def_id ) {
0 commit comments