-
Notifications
You must be signed in to change notification settings - Fork 14k
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
mod inner {
pub trait TraitA {}
pub trait TraitB: TraitA {}
}
struct Struct;
impl inner::TraitB for Struct {}Current output
error[E0277]: the trait bound `Struct: TraitA` is not satisfied
--> src/lib.rs:9:24
|
9 | impl inner::TraitB for Struct {}
| ^^^^^^ the trait `TraitA` is not implemented for `Struct`
|
help: this trait has no implementations, consider adding one
--> src/lib.rs:2:5
|
2 | pub trait TraitA {}
| ^^^^^^^^^^^^^^^^
note: required by a bound in `TraitB`
--> src/lib.rs:4:23
|
4 | pub trait TraitB: TraitA {}
| ^^^^^^ required by this bound in `TraitB`
= note: `TraitB` is a "sealed trait", because to implement it you also need to implement `inner::TraitA`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.Desired output
error[E0277]: the trait bound `Struct: TraitA` is not satisfied
--> src/lib.rs:9:24
|
9 | impl inner::TraitB for Struct {}
| ^^^^^^ the trait `TraitA` is not implemented for `Struct`
|
help: this trait has no implementations, consider adding one
--> src/lib.rs:2:5
|
2 | pub trait TraitA {}
| ^^^^^^^^^^^^^^^^
note: required by a bound in `TraitB`
--> src/lib.rs:4:23
|
4 | pub trait TraitB: TraitA {}
| ^^^^^^ required by this bound in `TraitB`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.Rationale and extra context
The error message includes a note stating that TraitB is a "sealed trait" because TraitA is inaccessible. However, this is incorrect; TraitA is public, and the error can be straightforwardly fixed by implementing it on Struct.
It looks like the conditions for triggering this note are not set correctly.
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.5Anything 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.