@@ -321,15 +321,18 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
321321 // `ForeignItem`s are handled separately.
322322 hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
323323 hir:: ItemKind :: TyAlias ( hir_ty, hir_generics) => {
324- if tcx. type_alias_is_lazy ( item. owner_id ) {
325- // Bounds of lazy type aliases and of eager ones that contain opaque types are respected.
326- // E.g: `type X = impl Trait;`, `type X = (impl Trait, Y);`.
327- let res = check_item_type ( tcx, def_id, hir_ty. span , UnsizedHandling :: Allow ) ;
328- check_variances_for_type_defn ( tcx, item, hir_generics) ;
329- res
324+ // [[[[ /!\ CRATER-ONLY /!\ ]]]]
325+ // Do not check the watered-down version of lazy type aliases for well-formedness.
326+ let ty = tcx. type_of ( item. owner_id ) . instantiate_identity ( ) ;
327+ let result = if !ty. references_error ( ) && ty. has_opaque_types ( ) {
328+ check_item_type ( tcx, def_id, hir_ty. span , UnsizedHandling :: Allow )
330329 } else {
331330 Ok ( ( ) )
331+ } ;
332+ if tcx. type_alias_is_lazy ( item. owner_id ) {
333+ check_variances_for_type_defn ( tcx, item, hir_generics) ;
332334 }
335+ result
333336 }
334337 _ => Ok ( ( ) ) ,
335338 } ;
@@ -1843,6 +1846,11 @@ fn check_variances_for_type_defn<'tcx>(
18431846 assert_eq ! ( ty_predicates. parent, None ) ;
18441847 let variances = tcx. variances_of ( item. owner_id ) ;
18451848
1849+ if let ItemKind :: TyAlias ( ..) = item. kind {
1850+ // [[[[ /!\ CRATER-ONLY /!\ ]]]]
1851+ return ;
1852+ }
1853+
18461854 let mut constrained_parameters: FxHashSet < _ > = variances
18471855 . iter ( )
18481856 . enumerate ( )
0 commit comments