diff options
| author | Boxy <rust@boxyuwu.dev> | 2025-03-12 11:23:20 +0000 |
|---|---|---|
| committer | Boxy <rust@boxyuwu.dev> | 2025-05-21 20:20:19 +0100 |
| commit | 996a185ba74755cb39a4fe24151ea65e671d4c0d (patch) | |
| tree | 3c66a51bb3acca1cde783103710f32d2a3211842 /compiler/rustc_trait_selection/src | |
| parent | 356f2d077498d0ebe5ec4f9cfef04293a2b17611 (diff) | |
Introduce `tcx.anon_const_kind` query
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 31b075db04b..e00be6425bc 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -553,7 +553,8 @@ pub fn try_evaluate_const<'tcx>( // // FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself // instead of having this logic here - let (args, typing_env) = if tcx.features().generic_const_exprs() + let (args, typing_env) = if tcx.def_kind(uv.def) == DefKind::AnonConst + && let ty::AnonConstKind::GCEConst = tcx.anon_const_kind(uv.def) && uv.has_non_region_infer() { // `feature(generic_const_exprs)` causes anon consts to inherit all parent generics. This can cause @@ -582,7 +583,10 @@ pub fn try_evaluate_const<'tcx>( (args, typing_env) } } - } else if tcx.def_kind(uv.def) == DefKind::AnonConst && uv.has_non_region_infer() { + } else if tcx.def_kind(uv.def) == DefKind::AnonConst + && let ty::AnonConstKind::RepeatExprCount = tcx.anon_const_kind(uv.def) + && uv.has_non_region_infer() + { // FIXME: remove this when `const_evaluatable_unchecked` is a hard error. // // Diagnostics will sometimes replace the identity args of anon consts in @@ -599,6 +603,7 @@ pub fn try_evaluate_const<'tcx>( let args = GenericArgs::identity_for_item(tcx, uv.def); let typing_env = ty::TypingEnv::post_analysis(tcx, uv.def); + (args, typing_env) } else { // FIXME: This codepath is reachable under `associated_const_equality` and in the |
