Open
Description
Given the following code:
trait Trait<'a>: Sized {
fn method(self)
where
for<'b> Self: Trait<'b>;
}
The current output is:
Compiling playground v0.0.1 (/playground)
error[E0283]: type annotations needed
--> src/lib.rs:1:1
|
1 | trait Trait<'a>: Sized {
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| cannot infer type for type parameter `Self`
| required by this bound in `Trait`
|
= note: cannot satisfy `Self: Trait<'a>`
help: consider specifying the type arguments in the function call
|
1 | trait Trait<'a>: Sized::<Self, 'a> {
| ^^^^^^^^^^^^
error: aborting due to previous error
I would’ve expected this code to compile. Even if there is a reason why it shouldn’t compile, the error message is about the most confusing/nonsensical error message I’ve ever seen. The “best” part is how it suggests adding arguments to Sized
.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Lifetimes / regionsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Trait systemDiagnostics: Confusing error or lint that should be reworked.Relevant to the compiler team, which will review and decide on the PR/issue.