Skip to content

Commit 11dc0a0

Browse files
committed
more anon const kind stuff
1 parent 79038c8 commit 11dc0a0

File tree

1 file changed

+9
-10
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+9
-10
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,9 @@ pub fn try_evaluate_const<'tcx>(
556556
//
557557
// FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself
558558
// instead of having this logic here
559-
let (args, typing_env) = if tcx.features().generic_const_exprs() {
559+
let (args, typing_env) = if tcx.def_kind(uv.def) == DefKind::AnonConst
560+
&& let ty::AnonConstKind::GCEConst = tcx.anon_const_kind(uv.def)
561+
{
560562
// We handle `generic_const_exprs` separately as reasonable ways of handling constants in the type system
561563
// completely fall apart under `generic_const_exprs` and makes this whole function Really hard to reason
562564
// about if you have to consider gce whatsoever.
@@ -598,11 +600,8 @@ pub fn try_evaluate_const<'tcx>(
598600
.with_post_analysis_normalized(tcx);
599601
(uv.args, typing_env)
600602
}
601-
} else if !tcx.features().min_generic_const_args()
602-
&& !tcx.features().associated_const_equality()
603-
// We check for anon consts so that when `associated_const_equality` bounds are
604-
// lowered on stable we still handle them correctly to avoid ICEs in CTFE.
605-
&& tcx.def_kind(uv.def) == DefKind::AnonConst
603+
} else if tcx.def_kind(uv.def) == DefKind::AnonConst
604+
&& let ty::AnonConstKind::RepeatExprCount = tcx.anon_const_kind(uv.def)
606605
{
607606
// FIXME: remove this when `const_evaluatable_unchecked` is a hard error.
608607
//
@@ -634,11 +633,11 @@ pub fn try_evaluate_const<'tcx>(
634633
(args, typing_env)
635634
} else {
636635
// We are only dealing with "truly" generic/uninferred constants here:
637-
// - `generic_const_exprs` has been handled separately in the first if
638-
// - `min_const_generics` repeat expr count hacks have been handled in the previous if
636+
// - GCEConsts have been separately handled
637+
// - Repeat expr hacks have also been separately handled
638+
// So we are free to simply defer evaluation here.
639639
//
640-
// So we are free to simply defer evaluation here. This does assume that `uv.args` has
641-
// already been normalized.
640+
// FIXME: This assumes the args already normalized
642641
if uv.args.has_non_region_param() || uv.args.has_non_region_infer() {
643642
return Err(EvaluateConstErr::HasGenericsOrInfers);
644643
}

0 commit comments

Comments
 (0)