@@ -328,16 +328,20 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
328328 hir:: ItemKind :: TraitAlias ( ..) => check_trait ( tcx, item) ,
329329 // `ForeignItem`s are handled separately.
330330 hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
331- hir:: ItemKind :: TyAlias ( hir_ty, hir_generics) => {
332- if tcx. type_alias_is_lazy ( item. owner_id ) {
333- // Bounds of lazy type aliases and of eager ones that contain opaque types are respected.
334- // E.g: `type X = impl Trait;`, `type X = (impl Trait, Y);`.
335- let res = check_item_type ( tcx, def_id, hir_ty. span , UnsizedHandling :: Allow ) ;
336- check_variances_for_type_defn ( tcx, item, hir_generics) ;
337- res
338- } else {
331+ hir:: ItemKind :: TyAlias ( hir_ty, hir_generics) if tcx. type_alias_is_lazy ( item. owner_id ) => {
332+ let res = enter_wf_checking_ctxt ( tcx, item. span , def_id, |wfcx| {
333+ let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
334+ let item_ty = wfcx. normalize ( hir_ty. span , Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
335+ wfcx. register_wf_obligation (
336+ hir_ty. span ,
337+ Some ( WellFormedLoc :: Ty ( def_id) ) ,
338+ item_ty. into ( ) ,
339+ ) ;
340+ check_where_clauses ( wfcx, item. span , def_id) ;
339341 Ok ( ( ) )
340- }
342+ } ) ;
343+ check_variances_for_type_defn ( tcx, item, hir_generics) ;
344+ res
341345 }
342346 _ => Ok ( ( ) ) ,
343347 } ;
@@ -1276,7 +1280,6 @@ fn check_item_fn(
12761280
12771281enum UnsizedHandling {
12781282 Forbid ,
1279- Allow ,
12801283 AllowIfForeignTail ,
12811284}
12821285
@@ -1294,7 +1297,6 @@ fn check_item_type(
12941297
12951298 let forbid_unsized = match unsized_handling {
12961299 UnsizedHandling :: Forbid => true ,
1297- UnsizedHandling :: Allow => false ,
12981300 UnsizedHandling :: AllowIfForeignTail => {
12991301 let tail =
13001302 tcx. struct_tail_for_codegen ( item_ty, wfcx. infcx . typing_env ( wfcx. param_env ) ) ;
0 commit comments