Skip to content

Commit e91fd0b

Browse files
authored
Rollup merge of #102466 - lcnr:const-equate-uwu, r=BoxyUwU
only allow `ConstEquate` with `feature(gce)`
2 parents 66de34b + 292f0c5 commit e91fd0b

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
@@ -492,19 +492,20 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
492492
}
493493

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

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

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

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

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

0 commit comments

Comments
 (0)