Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only emit one error per unsized binding, instead of one per usage #113183

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test for #56607
  • Loading branch information
estebank committed Oct 9, 2023
commit 3d86b8acdab25399fc921ab6b522943a02bac410
5 changes: 5 additions & 0 deletions tests/ui/sized/unsized-binding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
let x = *""; //~ ERROR E0277
println!("{}", x); //~ ERROR E0277
println!("{}", x); //~ ERROR E0277
}
39 changes: 39 additions & 0 deletions tests/ui/sized/unsized-binding.stderr
Original file line number Diff line number Diff line change
@@ -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`.