From a63ca2529154dc838c0998fce1a162bd507dc1fd Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Sun, 1 Dec 2024 16:37:06 -0400 Subject: [PATCH] Add failing tests for https://github.com/Rust-GPU/rust-gpu/issues/46 These passed before https://github.com/Rust-GPU/rust-gpu/commit/02cd3248ad13df8e0b4fa2962ceb57ac089e2d49. --- .../ptr/allocate_default_array_of_array.rs | 8 +++++++ .../allocate_default_array_of_array.stderr | 21 +++++++++++++++++++ ...locate_default_array_of_array_in_struct.rs | 14 +++++++++++++ ...te_default_array_of_array_in_struct.stderr | 21 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 tests/ui/lang/core/ptr/allocate_default_array_of_array.rs create mode 100644 tests/ui/lang/core/ptr/allocate_default_array_of_array.stderr create mode 100644 tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.rs create mode 100644 tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.stderr diff --git a/tests/ui/lang/core/ptr/allocate_default_array_of_array.rs b/tests/ui/lang/core/ptr/allocate_default_array_of_array.rs new file mode 100644 index 0000000000..d613a0be78 --- /dev/null +++ b/tests/ui/lang/core/ptr/allocate_default_array_of_array.rs @@ -0,0 +1,8 @@ +// build-fail + +use spirv_std::spirv; + +#[spirv(fragment)] +pub fn main() { + let x = [[1; 2]; 1]; +} diff --git a/tests/ui/lang/core/ptr/allocate_default_array_of_array.stderr b/tests/ui/lang/core/ptr/allocate_default_array_of_array.stderr new file mode 100644 index 0000000000..e78c9cf20d --- /dev/null +++ b/tests/ui/lang/core/ptr/allocate_default_array_of_array.stderr @@ -0,0 +1,21 @@ +error: cannot cast between pointer types + from `*i32` + to `*[i32; 2]` + --> $DIR/allocate_default_array_of_array.rs:7:13 + | +7 | let x = [[1; 2]; 1]; + | ^^^^^^^^^^^ + | +note: used from within `allocate_default_array_of_array::main` + --> $DIR/allocate_default_array_of_array.rs:7:13 + | +7 | let x = [[1; 2]; 1]; + | ^^^^^^^^^^^ +note: called by `main` + --> $DIR/allocate_default_array_of_array.rs:6:8 + | +6 | pub fn main() { + | ^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.rs b/tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.rs new file mode 100644 index 0000000000..2cb58133ff --- /dev/null +++ b/tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.rs @@ -0,0 +1,14 @@ +// build-fail + +use spirv_std::spirv; + +#[derive(Default)] +struct Foo { + bar: bool, + baz: [[u32; 2]; 1], +} + +#[spirv(fragment)] +pub fn main() { + let x = [Foo::default(); 1]; +} diff --git a/tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.stderr b/tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.stderr new file mode 100644 index 0000000000..80796a9e2a --- /dev/null +++ b/tests/ui/lang/core/ptr/allocate_default_array_of_array_in_struct.stderr @@ -0,0 +1,21 @@ +error: cannot cast between pointer types + from `*[[u32; 2]; 1]` + to `*struct Foo { baz: [[u32; 2]; 1], bar: bool }` + --> $DIR/allocate_default_array_of_array_in_struct.rs:13:13 + | +13 | let x = [Foo::default(); 1]; + | ^^^^^^^^^^^^^^^^^^^ + | +note: used from within `allocate_default_array_of_array_in_struct::main` + --> $DIR/allocate_default_array_of_array_in_struct.rs:13:13 + | +13 | let x = [Foo::default(); 1]; + | ^^^^^^^^^^^^^^^^^^^ +note: called by `main` + --> $DIR/allocate_default_array_of_array_in_struct.rs:12:8 + | +12 | pub fn main() { + | ^^^^ + +error: aborting due to 1 previous error +