@@ -1504,26 +1504,23 @@ fn is_normalizable_helper<'tcx>(
1504
1504
cache. insert ( ty, false ) ; // prevent recursive loops
1505
1505
let result = cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
1506
1506
let cause = rustc_middle:: traits:: ObligationCause :: dummy ( ) ;
1507
- if infcx. at ( & cause, param_env) . normalize ( ty) . is_err ( ) {
1508
- false
1509
- } else {
1507
+ if infcx. at ( & cause, param_env) . normalize ( ty) . is_ok ( ) {
1510
1508
match ty. kind ( ) {
1511
1509
ty:: Adt ( def, substs) => !def. variants . iter ( ) . any ( |variant| {
1512
1510
variant
1513
1511
. fields
1514
1512
. iter ( )
1515
1513
. any ( |field| !is_normalizable_helper ( cx, param_env, field. ty ( cx. tcx , substs) , cache) )
1516
1514
} ) ,
1517
- ty:: Ref ( _, pointee, _) | ty:: RawPtr ( ty:: TypeAndMut { ty : pointee, .. } ) => {
1518
- is_normalizable_helper ( cx, param_env, pointee, cache)
1519
- } ,
1520
- ty:: Array ( inner_ty, _) | ty:: Slice ( inner_ty) => is_normalizable_helper ( cx, param_env, inner_ty, cache) ,
1521
- ty:: Tuple ( tys) => !tys. iter ( ) . any ( |inner| match inner. unpack ( ) {
1522
- GenericArgKind :: Type ( inner_ty) => !is_normalizable_helper ( cx, param_env, inner_ty, cache) ,
1523
- _ => false ,
1515
+ _ => !ty. walk ( ) . any ( |generic_arg| !match generic_arg. unpack ( ) {
1516
+ GenericArgKind :: Type ( inner_ty) if inner_ty != ty => {
1517
+ is_normalizable_helper ( cx, param_env, inner_ty, cache)
1518
+ } ,
1519
+ _ => true , // if inner_ty == ty, we've already checked it
1524
1520
} ) ,
1525
- _ => true ,
1526
1521
}
1522
+ } else {
1523
+ false
1527
1524
}
1528
1525
} ) ;
1529
1526
cache. insert ( ty, result) ;
0 commit comments