@@ -48,8 +48,6 @@ pub use diverges::Diverges;
4848pub use expectation:: Expectation ;
4949pub use fn_ctxt:: * ;
5050pub use inherited:: { Inherited , InheritedBuilder } ;
51- use rustc_infer:: traits:: ObligationCause ;
52- use rustc_trait_selection:: traits:: NormalizeExt ;
5351
5452use crate :: check:: check_fn;
5553use crate :: coercion:: DynamicCoerceMany ;
@@ -235,9 +233,10 @@ fn typeck_with_fallback<'tcx>(
235233
236234 let typeck_results = Inherited :: build ( tcx, def_id) . enter ( |inh| {
237235 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 {
239239 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 ) ;
241240 <dyn AstConv < ' _ > >:: ty_of_fn ( & fcx, id, header. unsafety , header. abi , decl, None , None )
242241 } else {
243242 tcx. fn_sig ( def_id)
@@ -247,16 +246,10 @@ fn typeck_with_fallback<'tcx>(
247246
248247 // Compute the function signature from point of view of inside the fn.
249248 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 ) ;
258252 } else {
259- let fcx = FnCtxt :: new ( & inh, param_env, body. value . hir_id ) ;
260253 let expected_type = body_ty
261254 . and_then ( |ty| match ty. kind {
262255 hir:: TyKind :: Infer => Some ( <dyn AstConv < ' _ > >:: ast_ty_to_ty ( & fcx, ty) ) ,
@@ -316,8 +309,6 @@ fn typeck_with_fallback<'tcx>(
316309 fcx. check_expr_coercable_to_type ( & body. value , expected_type, None ) ;
317310
318311 fcx. write_ty ( id, expected_type) ;
319-
320- fcx
321312 } ;
322313
323314 fcx. type_inference_fallback ( ) ;
0 commit comments