-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Confusing error message: "expected 2 lifetime parameters" #60216
Comments
CC #60199 which shows how you can easily end with this code thanks to compiler suggestions. I believe the parser is unifying the two lifetimes as one because they have the same name. @nikomatsakis was this intended? I was under the impression that multiple uses |
It does seem like accepting only one rust/src/librustc/middle/resolve_lifetime.rs Lines 2204 to 2208 in e938c2b
|
In that case, the error just needs to be updated to say "only one elided lifetime is allowed" or something. But I'm very curious why that is the case. |
Hmm... also what are the odds that the same error was reported less than a day ago? Is this a regression or has it always done this? |
Changing the code I linked above to be
emits the following output (and changes some existing tests' output the same way)
It's always been the case since stabilization in 1.26, and probably since Jan 2017 when the code was originally written. My guess would be the "hidden lifetime parameters in types are deprecated" landing recently causing this type of code more likely to appear due to suggestions. I believe that this can be solved as a simple diagnostics fix, but am intrigued at how to communicate why |
There is always that compiler buzzword: ambiguous 😛 |
|
Similar issue, also because of clap. The Rust compiler suggested this:
If I understand the above discussion, then the compiler suggestion will fail, because of multiple elision. Can the compiler suggestion be adjusted? |
@joelparkerhenderson we do so when possible, but it is considered acceptable (at the very least tolerated) if a suggestion gives you wrong code that a subsequent compilation will receive a new suggestion that does get you to working code. |
The error message is helpful now (nightly 2023-01-15, clap 2.34.0):
|
This code:
Gives me the following error:
But I do have 2 lifetime parameters?
The text was updated successfully, but these errors were encountered: