diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index a1b75c22c4d..5cf33868ade 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -132,21 +132,16 @@ impl<'tcx> TerminatorClassifier<'tcx> for CallRecursion<'tcx> { return false; } let caller = body.source.def_id(); - let param_env = tcx.param_env(caller); + let typing_env = body.typing_env(tcx); let func_ty = func.ty(body, tcx); if let ty::FnDef(callee, args) = *func_ty.kind() { - let Ok(normalized_args) = - tcx.try_normalize_erasing_regions(ty::TypingEnv::from_param_env(param_env), args) - else { + let Ok(normalized_args) = tcx.try_normalize_erasing_regions(typing_env, args) else { return false; }; - let (callee, call_args) = if let Ok(Some(instance)) = Instance::try_resolve( - tcx, - ty::TypingEnv::from_param_env(param_env), - callee, - normalized_args, - ) { + let (callee, call_args) = if let Ok(Some(instance)) = + Instance::try_resolve(tcx, typing_env, callee, normalized_args) + { (instance.def_id(), instance.args) } else { (callee, normalized_args)