diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/const-generics/auxiliary | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/const-generics/auxiliary')
5 files changed, 60 insertions, 0 deletions
diff --git a/tests/ui/const-generics/auxiliary/const_generic_lib.rs b/tests/ui/const-generics/auxiliary/const_generic_lib.rs new file mode 100644 index 000000000..922f92d9f --- /dev/null +++ b/tests/ui/const-generics/auxiliary/const_generic_lib.rs @@ -0,0 +1,7 @@ +pub struct Struct<const N: usize>(pub [u8; N]); + +pub type Alias = Struct<2>; + +pub fn function(value: Struct<3>) -> u8 { + value.0[0] +} diff --git a/tests/ui/const-generics/auxiliary/crayte.rs b/tests/ui/const-generics/auxiliary/crayte.rs new file mode 100644 index 000000000..19a8bb0f4 --- /dev/null +++ b/tests/ui/const-generics/auxiliary/crayte.rs @@ -0,0 +1,16 @@ +// edition:2018 + +pub trait Foo<const N: usize> {} +struct Local; +impl<const N: usize> Foo<N> for Local {} + +pub fn out_foo<const N: usize>() -> impl Foo<N> { Local } +pub fn in_foo<const N: usize>(_: impl Foo<N>) {} + +pub async fn async_simple<const N: usize>(_: [u8; N]) {} +pub async fn async_out_foo<const N: usize>() -> impl Foo<N> { Local } +pub async fn async_in_foo<const N: usize>(_: impl Foo<N>) {} + +pub trait Bar<const N: usize> { + type Assoc: Foo<N>; +} diff --git a/tests/ui/const-generics/auxiliary/generics_of_parent.rs b/tests/ui/const-generics/auxiliary/generics_of_parent.rs new file mode 100644 index 000000000..5c2b1f4bd --- /dev/null +++ b/tests/ui/const-generics/auxiliary/generics_of_parent.rs @@ -0,0 +1,23 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +// library portion of regression test for #87674 +pub struct Foo<const N: usize>([(); N + 1]) +where + [(); N + 1]: ; + +// library portion of regression test for #87603 +pub struct S<T: Copy + Default, const N: usize> +where + [T; N * 2]: Sized, +{ + pub s: [T; N * 2], +} +impl<T: Default + Copy, const N: usize> S<T, N> +where + [T; N * 2]: Sized, +{ + pub fn test() -> Self { + S { s: [T::default(); N * 2] } + } +} diff --git a/tests/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs b/tests/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs new file mode 100644 index 000000000..cd5b8161d --- /dev/null +++ b/tests/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs @@ -0,0 +1,8 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +// library portion of testing that `impl Trait<{ expr }>` doesnt +// ice because of a `DefKind::TyParam` parent +pub fn foo<const N: usize>(foo: impl Into<[(); N + 1]>) { + foo.into(); +} diff --git a/tests/ui/const-generics/auxiliary/legacy-const-generics.rs b/tests/ui/const-generics/auxiliary/legacy-const-generics.rs new file mode 100644 index 000000000..67352a2fb --- /dev/null +++ b/tests/ui/const-generics/auxiliary/legacy-const-generics.rs @@ -0,0 +1,6 @@ +#![feature(rustc_attrs)] + +#[rustc_legacy_const_generics(1)] +pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { + [x, Y, z] +} |