From 10fa33441fa64a55ac1ccceaefca624ecd05b7d0 Mon Sep 17 00:00:00 2001 From: tiif Date: Sat, 8 Nov 2025 16:14:54 +0000 Subject: [PATCH] Drop environment when evaluating const without generic parameters --- compiler/rustc_trait_selection/src/traits/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 308d533e6899..6032bcacec6a 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -635,9 +635,10 @@ pub fn try_evaluate_const<'tcx>( return Err(EvaluateConstErr::HasGenericsOrInfers); } - let typing_env = infcx - .typing_env(tcx.erase_and_anonymize_regions(param_env)) - .with_post_analysis_normalized(tcx); + // Since there is no generic parameter, we can just drop the environment + // to prevent query cycle. + let typing_env = infcx.typing_env(ty::ParamEnv::empty()); + (uv.args, typing_env) } };