-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Wrong error when lifetime is appended to associated type #45817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Triage: no change. |
I actually ran into the same problem where the compiler message actually send me in the wrong direction until I realized The following code compiles just fine (playground). struct A;
fn f() -> A {
A
} but if I add the lifetime in the return type (playground) struct A;
fn f() -> A + 'static {
A
} I get this weird compiler message about
ExpectedI'd expect an error message explaining that Types cannot be mixed up with a lifetime constraint. Either trait is mixed with lifetime constraint, or types without constraints. |
Would this output have been clear to you?
|
@estebank that's definitely significantly better than what we currently have. I'd prefer a less obviously "parser state machine error" over E0404 and the accompanying text in your screenshot, but I can't really come up with a good option that isn't overly specific to this exact syntatic error. My rationale is that, devoid of any context, Perhaps something along the lines of e.g. "E0xxx: Invalid combination of non-trait type and type constraint"? (Everything past the first line is fine, this is just about the error code and brief text.) |
It's definitely an improvement. Thank you @estebank |
In the code fragment above, the problem is not that
Item
needs to point to a trait (is that even acceptable?) but rather that+ 'a
can only come after a trait.Ideally, this should actually be a different error ("lifetime specification here is not valid" or something along those lines) with the source of the error being the presence of
'a
and not the definition ofItem
, but if it remains E0404 then at least a hint should be provided along the lines ofThe text was updated successfully, but these errors were encountered: