From 46d8adeb616bcc2534d9a16ce8b3056ea12ea451 Mon Sep 17 00:00:00 2001 From: tiif Date: Fri, 21 Nov 2025 14:52:09 +0000 Subject: [PATCH 1/2] Use TypingEnv::fully_monomorphized for evaluating const without generic param path --- compiler/rustc_trait_selection/src/traits/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 6032bcacec6a4..01b7d354b4335 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -637,7 +637,7 @@ pub fn try_evaluate_const<'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()); + let typing_env = ty::TypingEnv::fully_monomorphized(); (uv.args, typing_env) } From af66b68f63ff869287a18f04486bc4ccf96ca6f9 Mon Sep 17 00:00:00 2001 From: tiif Date: Fri, 21 Nov 2025 15:02:06 +0000 Subject: [PATCH 2/2] refactor: make the match exhaustive --- compiler/rustc_trait_selection/src/traits/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 01b7d354b4335..3af90bde86e64 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -618,7 +618,7 @@ pub fn try_evaluate_const<'tcx>( (args, typing_env) } - _ => { + Some(ty::AnonConstKind::MCG) | Some(ty::AnonConstKind::NonTypeSystem) | None => { // We are only dealing with "truly" generic/uninferred constants here: // - GCEConsts have been handled separately // - Repeat expr count back compat consts have also been handled separately