@@ -321,15 +321,18 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
321
321
// `ForeignItem`s are handled separately.
322
322
hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
323
323
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 )
330
329
} else {
331
330
Ok ( ( ) )
331
+ } ;
332
+ if tcx. type_alias_is_lazy ( item. owner_id ) {
333
+ check_variances_for_type_defn ( tcx, item, hir_generics) ;
332
334
}
335
+ result
333
336
}
334
337
_ => Ok ( ( ) ) ,
335
338
} ;
@@ -1843,6 +1846,11 @@ fn check_variances_for_type_defn<'tcx>(
1843
1846
assert_eq ! ( ty_predicates. parent, None ) ;
1844
1847
let variances = tcx. variances_of ( item. owner_id ) ;
1845
1848
1849
+ if let ItemKind :: TyAlias ( ..) = item. kind {
1850
+ // [[[[ /!\ CRATER-ONLY /!\ ]]]]
1851
+ return ;
1852
+ }
1853
+
1846
1854
let mut constrained_parameters: FxHashSet < _ > = variances
1847
1855
. iter ( )
1848
1856
. enumerate ( )
0 commit comments