@@ -48,8 +48,6 @@ pub use diverges::Diverges;
48
48
pub use expectation:: Expectation ;
49
49
pub use fn_ctxt:: * ;
50
50
pub use inherited:: { Inherited , InheritedBuilder } ;
51
- use rustc_infer:: traits:: ObligationCause ;
52
- use rustc_trait_selection:: traits:: NormalizeExt ;
53
51
54
52
use crate :: check:: check_fn;
55
53
use crate :: coercion:: DynamicCoerceMany ;
@@ -235,9 +233,10 @@ fn typeck_with_fallback<'tcx>(
235
233
236
234
let typeck_results = Inherited :: build ( tcx, def_id) . enter ( |inh| {
237
235
let param_env = tcx. param_env ( def_id) ;
238
- let mut fcx = if let Some ( hir:: FnSig { header, decl, .. } ) = fn_sig {
236
+ let mut fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
237
+
238
+ if let Some ( hir:: FnSig { header, decl, .. } ) = fn_sig {
239
239
let fn_sig = if rustc_hir_analysis:: collect:: get_infer_ret_ty ( & decl. output ) . is_some ( ) {
240
- let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
241
240
<dyn AstConv < ' _ > >:: ty_of_fn ( & fcx, id, header. unsafety , header. abi , decl, None , None )
242
241
} else {
243
242
tcx. fn_sig ( def_id)
@@ -247,16 +246,10 @@ fn typeck_with_fallback<'tcx>(
247
246
248
247
// Compute the function signature from point of view of inside the fn.
249
248
let fn_sig = tcx. liberate_late_bound_regions ( def_id. to_def_id ( ) , fn_sig) ;
250
- // FIXME(compiler-errors): Remove
251
- let fn_sig = inh
252
- . register_infer_ok_obligations (
253
- inh. at ( & ObligationCause :: misc ( body. value . span , body_id. hir_id ) ,
254
- param_env,
255
- )
256
- . normalize ( fn_sig) ) ;
257
- check_fn ( & inh, param_env, fn_sig, decl, def_id, body, None ) . 0
249
+ let fn_sig = fcx. normalize ( body. value . span , fn_sig) ;
250
+
251
+ check_fn ( & mut fcx, fn_sig, decl, def_id, body, None ) ;
258
252
} else {
259
- let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
260
253
let expected_type = body_ty
261
254
. and_then ( |ty| match ty. kind {
262
255
hir:: TyKind :: Infer => Some ( <dyn AstConv < ' _ > >:: ast_ty_to_ty ( & fcx, ty) ) ,
@@ -316,8 +309,6 @@ fn typeck_with_fallback<'tcx>(
316
309
fcx. check_expr_coercable_to_type ( & body. value , expected_type, None ) ;
317
310
318
311
fcx. write_ty ( id, expected_type) ;
319
-
320
- fcx
321
312
} ;
322
313
323
314
fcx. type_inference_fallback ( ) ;
0 commit comments