From a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:19 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/unsized-locals/issue-67981.stderr | 5 +---- tests/ui/unsized-locals/rust-call.rs | 12 ++++++++++++ tests/ui/unsized-locals/rust-call.stderr | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tests/ui/unsized-locals/rust-call.rs create mode 100644 tests/ui/unsized-locals/rust-call.stderr (limited to 'tests/ui/unsized-locals') diff --git a/tests/ui/unsized-locals/issue-67981.stderr b/tests/ui/unsized-locals/issue-67981.stderr index a4b179ae2..13fdc037a 100644 --- a/tests/ui/unsized-locals/issue-67981.stderr +++ b/tests/ui/unsized-locals/issue-67981.stderr @@ -5,10 +5,7 @@ LL | let f: fn([u8]) = |_| {}; | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -help: function arguments must have a statically known size, borrowed types always have a known size - | -LL | let f: fn([u8]) = |&_| {}; - | + + = note: all function arguments must have a statically known size error: aborting due to previous error diff --git a/tests/ui/unsized-locals/rust-call.rs b/tests/ui/unsized-locals/rust-call.rs new file mode 100644 index 000000000..ff4075aa4 --- /dev/null +++ b/tests/ui/unsized-locals/rust-call.rs @@ -0,0 +1,12 @@ +#![feature(unsized_tuple_coercion)] +#![feature(unboxed_closures)] +#![feature(unsized_fn_params)] + +fn bad() -> extern "rust-call" fn(([u8],)) { todo!() } + +fn main() { + let f = bad(); + let slice: Box<([u8],)> = Box::new(([1; 8],)); + f(*slice); + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +} diff --git a/tests/ui/unsized-locals/rust-call.stderr b/tests/ui/unsized-locals/rust-call.stderr new file mode 100644 index 000000000..fff7ef75b --- /dev/null +++ b/tests/ui/unsized-locals/rust-call.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/rust-call.rs:10:7 + | +LL | f(*slice); + | ^^^^^^ doesn't have a size known at compile-time + | + = help: within `([u8],)`, the trait `Sized` is not implemented for `[u8]` + = note: required because it appears within the type `([u8],)` + = note: argument required to be sized due to `extern "rust-call"` ABI + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. -- cgit v1.2.3