diff options
| author | kadmin <julianknodt@gmail.com> | 2022-06-25 09:59:48 +0000 |
|---|---|---|
| committer | kadmin <julianknodt@gmail.com> | 2022-06-29 03:44:11 +0000 |
| commit | 1e40200b353926308a9a8a5f3349df8dc6bf8f80 (patch) | |
| tree | 676cdda3b340cf6f58ab6d04221488875eedb4c3 | |
| parent | e02d645110ae14f4a7f04d6bd5b05f2842488dda (diff) | |
| download | rust-1e40200b353926308a9a8a5f3349df8dc6bf8f80.tar.gz rust-1e40200b353926308a9a8a5f3349df8dc6bf8f80.zip | |
Erase regions in new abstract consts
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/const_evaluatable.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/const-generics/try_unify_ignore_lifetimes.rs | 33 |
2 files changed, 35 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 5d08ea99ac6..424eff2f621 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -236,7 +236,7 @@ impl<'tcx> AbstractConst<'tcx> { ) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> { let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?; debug!("AbstractConst::new({:?}) = {:?}", uv, inner); - Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs })) + Ok(inner.map(|inner| AbstractConst { inner, substs: tcx.erase_regions(uv.substs) })) } pub fn from_const( @@ -416,6 +416,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { // `AbstractConst`s should not contain any promoteds as they require references which // are not allowed. assert_eq!(ct.promoted, None); + assert_eq!(ct, self.tcx.erase_regions(ct)); } } } diff --git a/src/test/ui/const-generics/try_unify_ignore_lifetimes.rs b/src/test/ui/const-generics/try_unify_ignore_lifetimes.rs new file mode 100644 index 00000000000..2ae0ae70dd9 --- /dev/null +++ b/src/test/ui/const-generics/try_unify_ignore_lifetimes.rs @@ -0,0 +1,33 @@ +// check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct Num<const N: usize>; + +trait NumT { + const VALUE: usize; +} + +impl<const N: usize> NumT for Num<N> { + const VALUE: usize = N; +} + +struct Foo<'a, N: NumT>(&'a [u32; N::VALUE]) where [(); N::VALUE]:; + +trait Bar { + type Size: NumT; + + fn bar<'a>(foo: &Foo<'a, Self::Size>) where [(); Self::Size::VALUE]: { + todo!(); + } +} + +trait Baz<'a> { + type Size: NumT; + + fn baz(foo: &Foo<'a, Self::Size>) where [(); Self::Size::VALUE]: { + todo!(); + } +} + +fn main() {} |
