@@ -322,9 +322,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
322
322
hir:: ItemKind :: TraitAlias ( ..) => check_trait ( tcx, item) ,
323
323
// `ForeignItem`s are handled separately.
324
324
hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
325
- hir:: ItemKind :: TyAlias ( _, hir_ty, hir_generics)
326
- if tcx. type_alias_is_lazy ( item. owner_id ) =>
327
- {
325
+ hir:: ItemKind :: TyAlias ( _, hir_ty, _) if tcx. type_alias_is_lazy ( item. owner_id ) => {
328
326
let res = enter_wf_checking_ctxt ( tcx, item. span , def_id, |wfcx| {
329
327
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
330
328
let item_ty =
@@ -337,7 +335,6 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
337
335
check_where_clauses ( wfcx, item. span , def_id) ;
338
336
Ok ( ( ) )
339
337
} ) ;
340
- check_variances_for_type_defn ( tcx, item, hir_generics) ;
341
338
res
342
339
}
343
340
_ => Ok ( ( ) ) ,
@@ -2044,15 +2041,7 @@ fn check_variances_for_type_defn<'tcx>(
2044
2041
hir_generics : & hir:: Generics < ' tcx > ,
2045
2042
) {
2046
2043
match item. kind {
2047
- ItemKind :: Enum ( ..) | ItemKind :: Struct ( ..) | ItemKind :: Union ( ..) => {
2048
- // Ok
2049
- }
2050
- ItemKind :: TyAlias ( ..) => {
2051
- assert ! (
2052
- tcx. type_alias_is_lazy( item. owner_id) ,
2053
- "should not be computing variance of non-free type alias"
2054
- ) ;
2055
- }
2044
+ ItemKind :: Enum ( ..) | ItemKind :: Struct ( ..) | ItemKind :: Union ( ..) => { } // OK
2056
2045
kind => span_bug ! ( item. span, "cannot compute the variances of {kind:?}" ) ,
2057
2046
}
2058
2047
@@ -2195,7 +2184,6 @@ fn report_bivariance<'tcx>(
2195
2184
errors:: UnusedGenericParameterHelp :: AdtNoPhantomData { param_name }
2196
2185
}
2197
2186
}
2198
- ItemKind :: TyAlias ( ..) => errors:: UnusedGenericParameterHelp :: TyAlias { param_name } ,
2199
2187
item_kind => bug ! ( "report_bivariance: unexpected item kind: {item_kind:?}" ) ,
2200
2188
} ;
2201
2189
@@ -2268,9 +2256,6 @@ impl<'tcx> IsProbablyCyclical<'tcx> {
2268
2256
self . tcx . type_of ( field. did ) . instantiate_identity ( ) . visit_with ( self )
2269
2257
} )
2270
2258
}
2271
- DefKind :: TyAlias if self . tcx . type_alias_is_lazy ( def_id) => {
2272
- self . tcx . type_of ( def_id) . instantiate_identity ( ) . visit_with ( self )
2273
- }
2274
2259
_ => ControlFlow :: Continue ( ( ) ) ,
2275
2260
}
2276
2261
}
@@ -2280,17 +2265,12 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsProbablyCyclical<'tcx> {
2280
2265
type Result = ControlFlow < ( ) , ( ) > ;
2281
2266
2282
2267
fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> ControlFlow < ( ) , ( ) > {
2283
- let def_id = match ty. kind ( ) {
2284
- ty:: Adt ( adt_def, _) => Some ( adt_def. did ( ) ) ,
2285
- ty:: Alias ( ty:: Free , alias_ty) => Some ( alias_ty. def_id ) ,
2286
- _ => None ,
2287
- } ;
2288
- if let Some ( def_id) = def_id {
2289
- if def_id == self . item_def_id {
2268
+ if let Some ( adt_def) = ty. ty_adt_def ( ) {
2269
+ if adt_def. did ( ) == self . item_def_id {
2290
2270
return ControlFlow :: Break ( ( ) ) ;
2291
2271
}
2292
- if self . seen . insert ( def_id ) {
2293
- self . visit_def ( def_id ) ?;
2272
+ if self . seen . insert ( adt_def . did ( ) ) {
2273
+ self . visit_def ( adt_def . did ( ) ) ?;
2294
2274
}
2295
2275
}
2296
2276
ty. super_visit_with ( self )
0 commit comments