-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
use std::fmt::Debug;
async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}Current output
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `impl Debug + ?Sized` cannot be known at compilation time
--> src/lib.rs:3:43
|
3 | async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}
| ^^^^^^^^^^^^^^^^^^^
| |
| doesn't have a size known at compile-time
| this type parameter needs to be `Sized`
|
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
3 - async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}
3 + async fn arg_position_maybe_sized(_value: impl Debug) {}
|
help: function arguments must have a statically known size, borrowed types always have a known size
|
3 | async fn arg_position_maybe_sized(_value: &impl Debug + ?Sized) {}
| +
error[E0277]: the size for values of type `impl Debug + ?Sized` cannot be known at compilation time
--> src/lib.rs:3:35
|
3 | async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}
| ^^^^^^ ------------------- this type parameter needs to be `Sized`
| |
| doesn't have a size known at compile-time
|
= note: all local variables must have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
3 - async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}
3 + async fn arg_position_maybe_sized(_value: impl Debug) {}
|
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to 2 previous errorsDesired output
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `impl Debug + ?Sized` cannot be known at compilation time
--> src/lib.rs:3:35
|
3 | async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}
| ^^^^^^ ------------------- this type parameter needs to be `Sized`
| |
| doesn't have a size known at compile-time
|
= note: all local variables must have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
3 - async fn arg_position_maybe_sized(_value: impl Debug + ?Sized) {}
3 + async fn arg_position_maybe_sized(_value: impl Debug) {}
|
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to 2 previous errorsRationale and extra context
We should see just one diagnostic here, with all the necessary information from both current diagnostics combined. For example, on nightly one of the two diagnostics includes information about unsized fn arguments being an unstable feature (easy to see in the playground) -- ideally that info would be preserved when selecting which diagnostic to show (and how to merge them).
Other cases
Rust Version
rustc 1.91.1 (ed61e7d7e 2025-11-07)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: x86_64-unknown-linux-gnu
release: 1.91.1
LLVM version: 21.1.2Anything else?
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.