-
Notifications
You must be signed in to change notification settings - Fork 13.3k
NLL: missing note that "borrowed value needs to live until here" (sometimes?) #51168
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
The reason for this is indeed the closure, I think. We detect the error when analyzing the closure body, so it is hard for us to report a span that is outside the closure. I think this will be pretty tricky to fix and is maybe not that important. What we could probably do is take a different tactic: we could explain that I'm imagining:
for bonus points, we can highlight the |
I think that fixing this would also fix the examples here: |
Actually I'm marking this as a sub-issue of #51027 |
nominating for discussion on whether this should be kept open |
Decided to close. The current output is arguably clearer, and it would be quite challenging to add the "needs to live until here" note, since we don't have that information at the point where we report the error anymore. It's not clear that it adds a lot of information anyway. |
Consider: https://github.com/rust-lang/rust/blob/master/src/test/ui/span/issue-11925.nll.stderr
Compare it to: https://github.com/rust-lang/rust/blob/master/src/test/ui/span/issue-11925.stderr
The former is missing a note that "borrowed value needs to live until here"
Oftentimes, NLL diagnostics do include a note of the form "needs to live until use here." But apparently for this case (due to closures? Or destructors? Or both?) we do not have such a use to point at.
Anyway, this represents a regression in the informativeness of our diagnostics under NLL.
The text was updated successfully, but these errors were encountered: