From 3d86b8acdab25399fc921ab6b522943a02bac410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 30 Jun 2023 03:06:15 +0000 Subject: [PATCH] Add test for #56607 --- tests/ui/sized/unsized-binding.rs | 5 ++++ tests/ui/sized/unsized-binding.stderr | 39 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/ui/sized/unsized-binding.rs create mode 100644 tests/ui/sized/unsized-binding.stderr diff --git a/tests/ui/sized/unsized-binding.rs b/tests/ui/sized/unsized-binding.rs new file mode 100644 index 00000000000..7d410718612 --- /dev/null +++ b/tests/ui/sized/unsized-binding.rs @@ -0,0 +1,5 @@ +fn main() { + let x = *""; //~ ERROR E0277 + println!("{}", x); //~ ERROR E0277 + println!("{}", x); //~ ERROR E0277 +} diff --git a/tests/ui/sized/unsized-binding.stderr b/tests/ui/sized/unsized-binding.stderr new file mode 100644 index 00000000000..d508d84930a --- /dev/null +++ b/tests/ui/sized/unsized-binding.stderr @@ -0,0 +1,39 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/unsized-binding.rs:2:9 + | +LL | let x = *""; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/unsized-binding.rs:3:20 + | +LL | println!("{}", x); + | -- ^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | + = help: the trait `Sized` is not implemented for `str` +note: required by a bound in `core::fmt::rt::Argument::<'a>::new_display` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/unsized-binding.rs:4:20 + | +LL | println!("{}", x); + | -- ^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | + = help: the trait `Sized` is not implemented for `str` +note: required by a bound in `core::fmt::rt::Argument::<'a>::new_display` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`.