Skip to content

Commit b764120

Browse files
committed
add const-evaluatable_checked check back in
1 parent 09e6254 commit b764120

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
3030
span: Span,
3131
) -> Result<(), ErrorHandled> {
3232
debug!("is_const_evaluatable({:?}, {:?})", def, substs);
33-
// `AbstractConst::new` already returns `None` if `const_evaluatable_checked`
34-
// is not active, so we don't have to explicitly check for this here.
35-
if let Some(ct) = AbstractConst::new(infcx.tcx, def, substs) {
36-
for pred in param_env.caller_bounds() {
37-
match pred.skip_binders() {
38-
ty::PredicateAtom::ConstEvaluatable(b_def, b_substs) => {
39-
debug!("is_const_evaluatable: caller_bound={:?}, {:?}", b_def, b_substs);
40-
if b_def == def && b_substs == substs {
41-
debug!("is_const_evaluatable: caller_bound ~~> ok");
42-
return Ok(());
43-
} else if AbstractConst::new(infcx.tcx, b_def, b_substs)
44-
.map_or(false, |b_ct| try_unify(infcx.tcx, ct, b_ct))
45-
{
46-
debug!("is_const_evaluatable: abstract_const ~~> ok");
47-
return Ok(());
33+
if infcx.tcx.features().const_evaluatable_checked {
34+
if let Some(ct) = AbstractConst::new(infcx.tcx, def, substs) {
35+
for pred in param_env.caller_bounds() {
36+
match pred.skip_binders() {
37+
ty::PredicateAtom::ConstEvaluatable(b_def, b_substs) => {
38+
debug!("is_const_evaluatable: caller_bound={:?}, {:?}", b_def, b_substs);
39+
if b_def == def && b_substs == substs {
40+
debug!("is_const_evaluatable: caller_bound ~~> ok");
41+
return Ok(());
42+
} else if AbstractConst::new(infcx.tcx, b_def, b_substs)
43+
.map_or(false, |b_ct| try_unify(infcx.tcx, ct, b_ct))
44+
{
45+
debug!("is_const_evaluatable: abstract_const ~~> ok");
46+
return Ok(());
47+
}
4848
}
49+
_ => {} // don't care
4950
}
50-
_ => {} // don't care
5151
}
5252
}
5353
}

0 commit comments

Comments
 (0)