Skip to content

Commit dd51b36

Browse files
Add normalize hack back
1 parent 9be2f35 commit dd51b36

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

compiler/rustc_middle/src/ty/relate.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
574574
/// it.
575575
pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
576576
relation: &mut R,
577-
a: ty::Const<'tcx>,
578-
b: ty::Const<'tcx>,
577+
mut a: ty::Const<'tcx>,
578+
mut b: ty::Const<'tcx>,
579579
) -> RelateResult<'tcx, ty::Const<'tcx>> {
580580
debug!("{}.super_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
581581
let tcx = relation.tcx();
@@ -596,6 +596,17 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
596596
);
597597
}
598598

599+
// HACK(const_generics): We still need to eagerly evaluate consts when
600+
// relating them because during `normalize_param_env_or_error`,
601+
// we may relate an evaluated constant in a obligation against
602+
// an unnormalized (i.e. unevaluated) const in the param-env.
603+
// FIXME(generic_const_exprs): Once we always lazily unify unevaluated constants
604+
// these `eval` calls can be removed.
605+
if !relation.tcx().features().generic_const_exprs {
606+
a = a.eval(tcx, relation.param_env());
607+
b = b.eval(tcx, relation.param_env());
608+
}
609+
599610
// Currently, the values that can be unified are primitive types,
600611
// and those that derive both `PartialEq` and `Eq`, corresponding
601612
// to structural-match types.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// check-pass
2+
3+
pub trait CSpace<const N: usize> {
4+
type Traj;
5+
}
6+
7+
pub struct Const<const R: usize>;
8+
9+
pub trait Obstacle<CS, const N: usize> {
10+
fn trajectory_free<FT, S1>(&self, t: &FT)
11+
where
12+
CS::Traj: Sized,
13+
CS: CSpace<N>;
14+
}
15+
16+
// -----
17+
18+
const N: usize = 4;
19+
20+
struct ObstacleSpace2df32;
21+
22+
impl<CS> Obstacle<CS, N> for ObstacleSpace2df32 {
23+
fn trajectory_free<TF, S1>(&self, t: &TF)
24+
where
25+
CS::Traj: Sized,
26+
CS: CSpace<N>,
27+
{
28+
}
29+
}
30+
31+
fn main() {}

0 commit comments

Comments
 (0)