-
Notifications
You must be signed in to change notification settings - Fork 13.4k
improve error message when returning iterator with reference into stack frame #53882
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
With respect to impl Iterator, one thing I thought of is this
But in a way -- in this particular case -- it doesn't matter anyway, as there is nothing you could change that signature too that would work. |
I've assigned myself since I've been working on things in this area recently, but other things have come up as higher priority, so I might not get around to this for a few weeks. |
…nikomatsakis [NLL] Use new region infer errors when explaining borrows Use the new free region infer errors for explaining borrows This gives at least some explanation for why a borrow is expected to last for a certain free region. Also: * Reports E0373: "closure may outlive the current function" with NLL. * Special cases the case of returning a reference to (or value referencing) a local variable or temporary (E0515). * Special case assigning a reference to a local variable in a closure to a captured variable. (E0521) Closes #51026 - `regions-nested-fns-2.rs` isn't changed to that diagnostic, since that would not be the correct error here. Closes #51169 cc #53882 - The error is (IMO) better now, but it could be better when we trace lifetimes in these error messages. r? @nikomatsakis cc @pnkfelix
The current error is:
Which is already much better! I think "opaque type requires that" could point to the
|
This example (playground):
gives this error:
I think we could do better. For example, we don't explain anything about how
impl Iterator
disallows lifetimes; and I think we can clarify why `data is being dropped.I don't yet have a concrete suggestion, though, have to think about it.
Related to #52534 -- in some sense a specific instance of that.
The text was updated successfully, but these errors were encountered: