Skip to content

Commit 1e40200

Browse files
committed
Erase regions in new abstract consts
1 parent e02d645 commit 1e40200

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'tcx> AbstractConst<'tcx> {
236236
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
237237
let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?;
238238
debug!("AbstractConst::new({:?}) = {:?}", uv, inner);
239-
Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs }))
239+
Ok(inner.map(|inner| AbstractConst { inner, substs: tcx.erase_regions(uv.substs) }))
240240
}
241241

242242
pub fn from_const(
@@ -416,6 +416,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
416416
// `AbstractConst`s should not contain any promoteds as they require references which
417417
// are not allowed.
418418
assert_eq!(ct.promoted, None);
419+
assert_eq!(ct, self.tcx.erase_regions(ct));
419420
}
420421
}
421422
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// check-pass
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
struct Num<const N: usize>;
6+
7+
trait NumT {
8+
const VALUE: usize;
9+
}
10+
11+
impl<const N: usize> NumT for Num<N> {
12+
const VALUE: usize = N;
13+
}
14+
15+
struct Foo<'a, N: NumT>(&'a [u32; N::VALUE]) where [(); N::VALUE]:;
16+
17+
trait Bar {
18+
type Size: NumT;
19+
20+
fn bar<'a>(foo: &Foo<'a, Self::Size>) where [(); Self::Size::VALUE]: {
21+
todo!();
22+
}
23+
}
24+
25+
trait Baz<'a> {
26+
type Size: NumT;
27+
28+
fn baz(foo: &Foo<'a, Self::Size>) where [(); Self::Size::VALUE]: {
29+
todo!();
30+
}
31+
}
32+
33+
fn main() {}

0 commit comments

Comments
 (0)