@@ -1127,20 +1127,17 @@ fn replace_types<'tcx>(
1127
1127
deque. push_back ( ( param_ty, new_ty) ) ;
1128
1128
1129
1129
while let Some ( ( param_ty, new_ty) ) = deque. pop_front ( ) {
1130
- let new_generic_arg = ty:: GenericArg :: from ( new_ty) ;
1131
-
1132
1130
// If `replaced.is_empty()`, then `param_ty` and `new_ty` are those initially passed in.
1133
- if substs[ param_ty. index as usize ] != new_generic_arg
1134
- && !fn_sig
1135
- . inputs_and_output
1136
- . iter ( )
1137
- . enumerate ( )
1138
- . all ( |( i, ty) | ( replaced. is_empty ( ) && i == arg_index) || !contains_ty ( ty, param_ty. to_ty ( cx. tcx ) ) )
1131
+ if !fn_sig
1132
+ . inputs_and_output
1133
+ . iter ( )
1134
+ . enumerate ( )
1135
+ . all ( |( i, ty) | ( replaced. is_empty ( ) && i == arg_index) || !contains_ty ( ty, param_ty. to_ty ( cx. tcx ) ) )
1139
1136
{
1140
1137
return false ;
1141
1138
}
1142
1139
1143
- substs[ param_ty. index as usize ] = new_generic_arg ;
1140
+ substs[ param_ty. index as usize ] = ty :: GenericArg :: from ( new_ty ) ;
1144
1141
1145
1142
// The `replaced.insert(...)` check provides some protection against infinite loops.
1146
1143
if replaced. insert ( param_ty. index ) {
@@ -1155,7 +1152,9 @@ fn replace_types<'tcx>(
1155
1152
. mk_projection ( assoc_item. def_id , cx. tcx . mk_substs_trait ( new_ty, & [ ] ) ) ;
1156
1153
let projected_ty = cx. tcx . normalize_erasing_regions ( cx. param_env , projection) ;
1157
1154
1158
- deque. push_back ( ( * term_param_ty, projected_ty) ) ;
1155
+ if substs[ term_param_ty. index as usize ] != ty:: GenericArg :: from ( projected_ty) {
1156
+ deque. push_back ( ( * term_param_ty, projected_ty) ) ;
1157
+ }
1159
1158
}
1160
1159
}
1161
1160
}
0 commit comments