@@ -1504,26 +1504,23 @@ fn is_normalizable_helper<'tcx>(
15041504 cache. insert ( ty, false ) ; // prevent recursive loops
15051505 let result = cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
15061506 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 ( ) {
15101508 match ty. kind ( ) {
15111509 ty:: Adt ( def, substs) => !def. variants . iter ( ) . any ( |variant| {
15121510 variant
15131511 . fields
15141512 . iter ( )
15151513 . any ( |field| !is_normalizable_helper ( cx, param_env, field. ty ( cx. tcx , substs) , cache) )
15161514 } ) ,
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
15241520 } ) ,
1525- _ => true ,
15261521 }
1522+ } else {
1523+ false
15271524 }
15281525 } ) ;
15291526 cache. insert ( ty, result) ;
0 commit comments