diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2023-04-25 19:38:42 +0200 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2023-04-25 23:32:13 +0200 |
| commit | 2f354482b828578d629e1139e9b3471e44519118 (patch) | |
| tree | d86bd4becc1a9ea1cbc393d626762cd675875c98 /tests | |
| parent | a7aa20517c80161a2ffe7c0c25fc2e0140c43c90 (diff) | |
| download | rust-2f354482b828578d629e1139e9b3471e44519118.tar.gz rust-2f354482b828578d629e1139e9b3471e44519118.zip | |
Add regression tests for const-generic IATs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/associated-inherent-types/const-generics.rs | 23 | ||||
| -rw-r--r-- | tests/ui/associated-inherent-types/generic-const-exprs.rs | 28 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/ui/associated-inherent-types/const-generics.rs b/tests/ui/associated-inherent-types/const-generics.rs new file mode 100644 index 00000000000..5b7c00bccba --- /dev/null +++ b/tests/ui/associated-inherent-types/const-generics.rs @@ -0,0 +1,23 @@ +// Regression test for issue #109759. +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo; + +struct Bar<const X: usize>([(); X]); + +impl<const X: usize> Bar<X> { + pub fn new() -> Self { + Self([(); X]) + } +} + +impl Foo { + type Bar<const X: usize> = Bar<X>; +} + +fn main() { + let _ = Foo::Bar::<10>::new(); +} diff --git a/tests/ui/associated-inherent-types/generic-const-exprs.rs b/tests/ui/associated-inherent-types/generic-const-exprs.rs new file mode 100644 index 00000000000..a4ac0ecfa4c --- /dev/null +++ b/tests/ui/associated-inherent-types/generic-const-exprs.rs @@ -0,0 +1,28 @@ +// check-pass + +#![feature(inherent_associated_types, generic_const_exprs)] +#![allow(incomplete_features)] + +struct Parent<const O: usize>; + +impl<const O: usize> Parent<O> { + type Mapping<const I: usize> = Store<{ O + I }> + where + [(); O + I]: + ; +} + +struct Store<const N: usize>; + +impl<const N: usize> Store<N> { + const REIFIED: usize = N; + + fn reify() -> usize { + N + } +} + +fn main() { + let _ = Parent::<2>::Mapping::<{ 12 * 2 }>::REIFIED; + let _ = Parent::<1>::Mapping::<{ 2 * 5 }>::reify(); +} |
