Skip to content

Commit b4d992f

Browse files
authored
Rollup merge of #111103 - BoxyUwU:normal_fold_with_gce_norm, r=compiler-errors
correctly recurse when expanding anon consts recursing with `super_fold_with` is wrong in case `bac` is itself normalizable, the test that was supposed to test for this being wrong did not actually test for this in reality because of the usage of `{ (N) }` instead of `{{ N }}`. The former resulting in a simple `ConstKind::Param` instead of `ConstKind::Unevaluated`. Tbh generally this test seems very brittle and it will be a lot easier to test once we have normalization of assoc consts since then we can just test that `T::ASSOC` normalizes to some `U::OTHER` which normalizes to some third thing. r? `@compiler-errors`
2 parents f2bc7e0 + 4d0887e commit b4d992f

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

compiler/rustc_middle/src/ty/abstract_const.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ impl<'tcx> TyCtxt<'tcx> {
6363
Err(e) => self.tcx.const_error_with_guaranteed(c.ty(), e),
6464
Ok(Some(bac)) => {
6565
let substs = self.tcx.erase_regions(uv.substs);
66-
bac.subst(self.tcx, substs)
66+
let bac = bac.subst(self.tcx, substs);
67+
return bac.fold_with(self);
6768
}
6869
Ok(None) => c,
6970
},

tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22
#![feature(generic_const_exprs)]
33
#![allow(incomplete_features, unused_parens, unused_braces)]
44

5-
fn zero_init<const N: usize>() -> Substs1<{ (N) }>
5+
fn zero_init<const N: usize>() -> Substs1<{{ N }}>
66
where
7-
[u8; { (N) }]: ,
7+
[u8; {{ N }}]: ,
88
{
9-
Substs1([0; { (N) }])
9+
Substs1([0; {{ N }}])
1010
}
1111

12-
struct Substs1<const N: usize>([u8; { (N) }])
12+
struct Substs1<const N: usize>([u8; {{ N }}])
1313
where
14-
[(); { (N) }]: ;
14+
[(); {{ N }}]: ;
1515

16-
fn substs2<const M: usize>() -> Substs1<{ (M) }> {
17-
zero_init::<{ (M) }>()
16+
fn substs2<const M: usize>() -> Substs1<{{ M }}> {
17+
zero_init::<{{ M }}>()
1818
}
1919

20-
fn substs3<const L: usize>() -> Substs1<{ (L) }> {
21-
substs2::<{ (L) }>()
20+
fn substs3<const L: usize>() -> Substs1<{{ L }}> {
21+
substs2::<{{ L }}>()
2222
}
2323

2424
fn main() {
2525
assert_eq!(substs3::<2>().0, [0; 2]);
2626
}
2727

28-
// Test that the implicit ``{ (L) }`` bound on ``substs3`` satisfies the
29-
// ``{ (N) }`` bound on ``Substs1``
28+
// Test that the implicit ``{{ L }}`` bound on ``substs3`` satisfies the
29+
// ``{{ N }}`` bound on ``Substs1``
30+
// FIXME(generic_const_exprs): come up with a less brittle test for this using assoc consts
31+
// once normalization is implemented for them.

0 commit comments

Comments
 (0)