Skip to content

Commit 292f0c5

Browse files
committed
only allow ConstEquate with feature(gce)
1 parent 1536a53 commit 292f0c5

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

compiler/rustc_trait_selection/src/traits/fulfill.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,20 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
495495
}
496496

497497
ty::PredicateKind::ConstEquate(c1, c2) => {
498+
assert!(
499+
self.selcx.tcx().features().generic_const_exprs,
500+
"`ConstEquate` without a feature gate: {c1:?} {c2:?}",
501+
);
498502
debug!(?c1, ?c2, "equating consts");
499-
let tcx = self.selcx.tcx();
500-
if tcx.features().generic_const_exprs {
501-
// FIXME: we probably should only try to unify abstract constants
502-
// if the constants depend on generic parameters.
503-
//
504-
// Let's just see where this breaks :shrug:
505-
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
506-
(c1.kind(), c2.kind())
507-
{
508-
if infcx.try_unify_abstract_consts(a, b, obligation.param_env) {
509-
return ProcessResult::Changed(vec![]);
510-
}
503+
// FIXME: we probably should only try to unify abstract constants
504+
// if the constants depend on generic parameters.
505+
//
506+
// Let's just see where this breaks :shrug:
507+
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
508+
(c1.kind(), c2.kind())
509+
{
510+
if infcx.try_unify_abstract_consts(a, b, obligation.param_env) {
511+
return ProcessResult::Changed(vec![]);
511512
}
512513
}
513514

compiler/rustc_trait_selection/src/traits/select/mod.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -677,19 +677,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
677677
}
678678

679679
ty::PredicateKind::ConstEquate(c1, c2) => {
680+
assert!(
681+
self.tcx().features().generic_const_exprs,
682+
"`ConstEquate` without a feature gate: {c1:?} {c2:?}",
683+
);
680684
debug!(?c1, ?c2, "evaluate_predicate_recursively: equating consts");
681685

682-
if self.tcx().features().generic_const_exprs {
683-
// FIXME: we probably should only try to unify abstract constants
684-
// if the constants depend on generic parameters.
685-
//
686-
// Let's just see where this breaks :shrug:
687-
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
688-
(c1.kind(), c2.kind())
689-
{
690-
if self.infcx.try_unify_abstract_consts(a, b, obligation.param_env) {
691-
return Ok(EvaluatedToOk);
692-
}
686+
// FIXME: we probably should only try to unify abstract constants
687+
// if the constants depend on generic parameters.
688+
//
689+
// Let's just see where this breaks :shrug:
690+
if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
691+
(c1.kind(), c2.kind())
692+
{
693+
if self.infcx.try_unify_abstract_consts(a, b, obligation.param_env) {
694+
return Ok(EvaluatedToOk);
693695
}
694696
}
695697

0 commit comments

Comments
 (0)