-
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
cannot infer appropriate lifetime
error message is confusing
#42317
Comments
Yes. These messages are definitely bad. In truth, although this looks like one message, it covers a very wide range of scenarios. What I've been doing is trying to analyze and figure out how to handle those scenarios separately. At the moment, @gaurikholkar is actually actively at work on the first such case, which has to do with returning data when one of the regions in question is a named lifetime and the other is anonymous. We plan to go from there and carve out many more cases to improve. Thanks for the "thought process", I'll add this issue to my etherpad where I am tracking and brainstorming. (I should also open an issue on the various ideas that @gaurikholkar and I have been kicking around.) I think in the meantime I will close this issue, though, in favor of opening one a more general one. |
See also #42516 |
Thanks Niko. I'm glad the Rust community sees worth in improving error messages :) |
Hi,
There is a class of error message which: a) is common, b) I've always been very confused by.
Here's an example:
The first issue I have is the sheer amount of information I am bombarded with. I can't keep all these details in my head while I am digesting the message.
Second, the flow of the error message and the locality of the details therein are confusing. Let me demonstrate by showing my trail of thought as I read the error:
Being brutally honest, usually by this point I've given up trying to understand the error message and have instead resorted to brute force, adding/changing different lifetime annotations until the program compiles.
I guess this relates to rust-lang/nomicon#2, where I was trying to improve the documentation so that beginners could better understand lifetimes. Despite having written that PR, I still don't feel confident I've understood.
There has to be a more intuitive way for the compiler to explain what is wrong. Any ideas?
(For context: I've been using Rust for probably 2 or 3 months, however, I am an experienced programmer in many other languages)
The text was updated successfully, but these errors were encountered: