-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-trait-systemArea: Trait systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-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
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
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-trait-systemArea: Trait systemArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-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.