@@ -1001,7 +1001,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
1001
1001
& mut self ,
1002
1002
t : ty:: Binder < ' tcx , T > ,
1003
1003
) -> ty:: Binder < ' tcx , T > {
1004
- if !t. has_placeholders ( ) && !t. has_infer_regions ( ) {
1004
+ if !t. has_placeholders ( ) && !t. has_infer ( ) {
1005
1005
return t;
1006
1006
}
1007
1007
self . current_index . shift_in ( 1 ) ;
@@ -1048,6 +1048,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
1048
1048
}
1049
1049
1050
1050
fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1051
+ let ty = self . infcx . shallow_resolve ( ty) ;
1051
1052
match * ty. kind ( ) {
1052
1053
ty:: Placeholder ( p) => {
1053
1054
let replace_var = self . mapped_types . get ( & p) ;
@@ -1063,16 +1064,23 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
1063
1064
) ;
1064
1065
Ty :: new_bound ( self . infcx . tcx , db, * replace_var)
1065
1066
}
1066
- None => ty,
1067
+ None => {
1068
+ if ty. has_infer ( ) {
1069
+ ty. super_fold_with ( self )
1070
+ } else {
1071
+ ty
1072
+ }
1073
+ }
1067
1074
}
1068
1075
}
1069
1076
1070
- _ if ty. has_placeholders ( ) || ty. has_infer_regions ( ) => ty. super_fold_with ( self ) ,
1077
+ _ if ty. has_placeholders ( ) || ty. has_infer ( ) => ty. super_fold_with ( self ) ,
1071
1078
_ => ty,
1072
1079
}
1073
1080
}
1074
1081
1075
1082
fn fold_const ( & mut self , ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
1083
+ let ct = self . infcx . shallow_resolve ( ct) ;
1076
1084
if let ty:: ConstKind :: Placeholder ( p) = ct. kind ( ) {
1077
1085
let replace_var = self . mapped_consts . get ( & p) ;
1078
1086
match replace_var {
@@ -1087,7 +1095,13 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
1087
1095
) ;
1088
1096
ty:: Const :: new_bound ( self . infcx . tcx , db, * replace_var, ct. ty ( ) )
1089
1097
}
1090
- None => ct,
1098
+ None => {
1099
+ if ct. has_infer ( ) {
1100
+ ct. super_fold_with ( self )
1101
+ } else {
1102
+ ct
1103
+ }
1104
+ }
1091
1105
}
1092
1106
} else {
1093
1107
ct. super_fold_with ( self )
0 commit comments