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 +