-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Better errors when rustc cannot derive lifetimes #30102
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
Better errors when rustc cannot derive lifetimes #30102
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
r? @Manishearth |
@bors r+ force Thanks! |
📌 Commit 9569c63 has been approved by |
@bors r- |
This needs a test. |
Wait, sorry, we should add a test for this. Could you add one to |
fileline_help!(tcx.sess, default_span, | ||
"this function's return type contains a borrowed value, but \ | ||
there is no value for it to be borrowed from"); | ||
fileline_help!(tcx.sess, default_span, | ||
"consider giving it a 'static lifetime"); | ||
} else if !any_lifetimes { | ||
fileline_help!(tcx.sess, default_span, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the error message different between this case and the previous one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the previous message implied that there were no arguments to draw from, and I was hoping to make the message as explicit as possible; I think if they were made the same they would be slightly more confusing. I don't feel strongly on this or anything, I'd be happy to change it so they have the same message if that's the consensus.
Also yeah, I'll do the tests.
@bors r+ Sorry, didn't notice the new commit. Thanks! |
📌 Commit 829e8bf has been approved by |
Fixes #30086