@@ -2127,34 +2127,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2127
2127
}
2128
2128
}
2129
2129
2130
- /// Apply "fallbacks" to some types
2131
- /// unconstrained types get replaced with ! or () (depending on whether
2132
- /// feature(never_type) is enabled), unconstrained ints with i32, and
2133
- /// unconstrained floats with f64.
2134
- fn default_type_parameters ( & self ) {
2135
- // Defaulting inference variables becomes very dubious if we have
2136
- // encountered type-checking errors. Therefore, if we think we saw
2137
- // some errors in this function, just resolve all uninstanted type
2138
- // varibles to TyError.
2139
- if self . is_tainted_by_errors ( ) {
2140
- for ty in & self . unsolved_variables ( ) {
2141
- if let ty:: TyInfer ( _) = self . shallow_resolve ( ty) . sty {
2142
- debug ! ( "default_type_parameters: defaulting `{:?}` to error" , ty) ;
2143
- self . demand_eqtype ( syntax_pos:: DUMMY_SP , * ty, self . tcx ( ) . types . err ) ;
2144
- }
2145
- }
2146
- return ;
2147
- }
2148
-
2149
- for ty in & self . unsolved_variables ( ) {
2150
- let resolved = self . resolve_type_vars_if_possible ( ty) ;
2151
- if resolved. is_ty_infer ( ) {
2152
- self . apply_diverging_fallback_to_type ( ty) ;
2153
- self . apply_numeric_fallback_to_type ( ty) ;
2154
- }
2155
- }
2156
- }
2157
-
2158
2130
fn apply_diverging_fallback_to_type ( & self , ty : Ty < ' tcx > ) {
2159
2131
assert ! ( ty. is_ty_infer( ) ) ;
2160
2132
if self . type_var_diverges ( ty) {
@@ -2185,7 +2157,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
2185
2157
assert ! ( self . deferred_call_resolutions. borrow( ) . is_empty( ) ) ;
2186
2158
2187
2159
self . select_obligations_where_possible ( ) ;
2188
- self . default_type_parameters ( ) ;
2160
+
2161
+ // Apply fallbacks to unsolved variables.
2162
+ // Non-numerics get replaced with ! or () (depending on whether
2163
+ // feature(never_type) is enabled), unconstrained ints with i32,
2164
+ // unconstrained floats with f64.
2165
+ for ty in & self . unsolved_variables ( ) {
2166
+ if self . is_tainted_by_errors ( ) {
2167
+ // Defaulting inference variables becomes very dubious if we have
2168
+ // encountered type-checking errors. In that case,
2169
+ // just resolve all uninstanted type variables to TyError.
2170
+ debug ! ( "default_type_parameters: defaulting `{:?}` to error" , ty) ;
2171
+ self . demand_eqtype ( syntax_pos:: DUMMY_SP , * ty, self . tcx ( ) . types . err ) ;
2172
+ } else {
2173
+ self . apply_diverging_fallback_to_type ( ty) ;
2174
+ self . apply_numeric_fallback_to_type ( ty) ;
2175
+ }
2176
+ }
2189
2177
2190
2178
let mut fulfillment_cx = self . fulfillment_cx . borrow_mut ( ) ;
2191
2179
0 commit comments