Skip to content

Commit d2152f4

Browse files
committed
Remove fast path for perf
1 parent b113e1f commit d2152f4

File tree

1 file changed

+25
-14
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+25
-14
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

+25-14
Original file line numberDiff line numberDiff line change
@@ -646,20 +646,20 @@ pub fn try_evaluate_const<'tcx>(
646646
// it is well formed as otherwise CTFE will ICE. For the same reasons as with
647647
// deferring evaluation of generic/uninferred constants, we do not have to worry
648648
// about `generic_const_expr`
649-
if tcx.def_kind(uv.def) == DefKind::AnonConst
650-
&& tcx.predicates_of(uv.def).predicates.is_empty()
651-
{
652-
// ... skip doing any work
653-
} else {
654-
let input = infcx
655-
.canonicalize_query(param_env.and(uv), &mut OriginalQueryValues::default());
656-
if !tcx.check_constant_safe_to_evaluate(input) {
657-
let e = tcx.dcx().delayed_bug(
658-
"Attempted to evaluate illformed constant but no error emitted",
659-
);
660-
return Err(EvaluateConstErr::EvaluationFailure(e));
661-
}
662-
}
649+
// if tcx.def_kind(uv.def) == DefKind::AnonConst
650+
// && tcx.predicates_of(uv.def).predicates.is_empty()
651+
// {
652+
// // ... skip doing any work
653+
// } else {
654+
// let input = infcx
655+
// .canonicalize_query(param_env.and(uv), &mut OriginalQueryValues::default());
656+
// if !tcx.check_constant_safe_to_evaluate(input) {
657+
// let e = tcx.dcx().delayed_bug(
658+
// "Attempted to evaluate illformed constant but no error emitted",
659+
// );
660+
// return Err(EvaluateConstErr::EvaluationFailure(e));
661+
// }
662+
// }
663663

664664
let typing_env = infcx
665665
.typing_env(tcx.erase_regions(param_env))
@@ -670,6 +670,17 @@ pub fn try_evaluate_const<'tcx>(
670670
let uv = ty::UnevaluatedConst::new(uv.def, args);
671671
let erased_uv = tcx.erase_regions(uv);
672672

673+
if !tcx.features().generic_const_exprs() {
674+
let input = infcx
675+
.canonicalize_query(param_env.and(uv), &mut OriginalQueryValues::default());
676+
if !tcx.check_constant_safe_to_evaluate(input) {
677+
let e = tcx.dcx().delayed_bug(
678+
"Attempted to evaluate illformed constant but no error emitted",
679+
);
680+
return Err(EvaluateConstErr::EvaluationFailure(e));
681+
}
682+
}
683+
673684
use rustc_middle::mir::interpret::ErrorHandled;
674685
match tcx.const_eval_resolve_for_typeck(typing_env, erased_uv, DUMMY_SP) {
675686
Ok(Ok(val)) => Ok(ty::Const::new_value(

0 commit comments

Comments
 (0)