-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
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
trait Trait {
fn foo(&self);
}
// Implicitly requires `T: Sized`.
// Adding a `?Sized` bound makes the error go away.
impl<T> Trait for T {
fn foo(&self) {}
}
// `[u8]` does not implement `Sized`.
fn test(x: &[u8]) {
Trait::foo(x)
}Current output
error[E0277]: the trait bound `[u8]: Trait` is not satisfied
--> src/lib.rs:13:16
|
13 | Trait::foo(x)
| ---------- ^ the trait `Trait` is not implemented for `[u8]`
| |
| required by a bound introduced by this call
|
note: required for `[u8]` to implement `Trait`
--> src/lib.rs:7:9
|
7 | impl<T> Trait for T {
| - ^^^^^ ^
| |
| unsatisfied trait bound introduced here
help: consider borrowing here
|
13 | Trait::foo(&x)
| +
13 | Trait::foo(&mut x)
| ++++
For more information about this error, try `rustc --explain E0277`.Desired output
error[E0277]: the trait bound `[u8]: Trait` is not satisfied
--> src/lib.rs:12:16
|
13 | Trait::foo(x)
| ---------- ^ the trait `Sized` is not implemented for `[u8]`
| |
| required by a bound introduced by this call
|
note: required for `[u8]` to implement `Trait`
--> src/lib.rs:6:9
|
7 | impl<T> Trait for T {
| - ^^^^^ ^
| |
| unsatisfied trait bound introduced here
help: consider relaxing the implicit `Sized` bound
|
7 | impl<T: ?Sized> Trait for T {
| ++++++++
For more information about this error, try `rustc --explain E0277`.Rationale and extra context
No response
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-pc-windows-gnu
release: 1.90.0
LLVM version: 20.1.8Anything else?
No response
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.