From 2f354482b828578d629e1139e9b3471e44519118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Tue, 25 Apr 2023 19:38:42 +0200 Subject: [PATCH] Add regression tests for const-generic IATs --- .../const-generics.rs | 23 +++++++++++++++ .../generic-const-exprs.rs | 28 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/ui/associated-inherent-types/const-generics.rs create mode 100644 tests/ui/associated-inherent-types/generic-const-exprs.rs 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 0000000000000..5b7c00bccba70 --- /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([(); X]); + +impl Bar { + pub fn new() -> Self { + Self([(); X]) + } +} + +impl Foo { + type Bar = Bar; +} + +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 0000000000000..a4ac0ecfa4cf9 --- /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; + +impl Parent { + type Mapping = Store<{ O + I }> + where + [(); O + I]: + ; +} + +struct Store; + +impl Store { + const REIFIED: usize = N; + + fn reify() -> usize { + N + } +} + +fn main() { + let _ = Parent::<2>::Mapping::<{ 12 * 2 }>::REIFIED; + let _ = Parent::<1>::Mapping::<{ 2 * 5 }>::reify(); +}