@@ -322,9 +322,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
322322 hir:: ItemKind :: TraitAlias ( ..) => check_trait ( tcx, item) ,
323323 // `ForeignItem`s are handled separately.
324324 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 ) => {
328326 let res = enter_wf_checking_ctxt ( tcx, item. span , def_id, |wfcx| {
329327 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
330328 let item_ty =
@@ -337,7 +335,6 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
337335 check_where_clauses ( wfcx, item. span , def_id) ;
338336 Ok ( ( ) )
339337 } ) ;
340- check_variances_for_type_defn ( tcx, item, hir_generics) ;
341338 res
342339 }
343340 _ => Ok ( ( ) ) ,
@@ -2044,15 +2041,7 @@ fn check_variances_for_type_defn<'tcx>(
20442041 hir_generics : & hir:: Generics < ' tcx > ,
20452042) {
20462043 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
20562045 kind => span_bug ! ( item. span, "cannot compute the variances of {kind:?}" ) ,
20572046 }
20582047
@@ -2195,7 +2184,6 @@ fn report_bivariance<'tcx>(
21952184 errors:: UnusedGenericParameterHelp :: AdtNoPhantomData { param_name }
21962185 }
21972186 }
2198- ItemKind :: TyAlias ( ..) => errors:: UnusedGenericParameterHelp :: TyAlias { param_name } ,
21992187 item_kind => bug ! ( "report_bivariance: unexpected item kind: {item_kind:?}" ) ,
22002188 } ;
22012189
@@ -2268,9 +2256,6 @@ impl<'tcx> IsProbablyCyclical<'tcx> {
22682256 self . tcx . type_of ( field. did ) . instantiate_identity ( ) . visit_with ( self )
22692257 } )
22702258 }
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- }
22742259 _ => ControlFlow :: Continue ( ( ) ) ,
22752260 }
22762261 }
@@ -2280,17 +2265,12 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsProbablyCyclical<'tcx> {
22802265 type Result = ControlFlow < ( ) , ( ) > ;
22812266
22822267 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 {
22902270 return ControlFlow :: Break ( ( ) ) ;
22912271 }
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 ( ) ) ?;
22942274 }
22952275 }
22962276 ty. super_visit_with ( self )
0 commit comments