-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
MIR-borrowck: emit "foo
does not live long enough" instead of borrow errors
#45989
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7db49b9
Deduplicated borrow checking errors.
davidtwco a98aff7
Updated test to reflect expected Mir output.
davidtwco ce8967a
Modified to output intended error.
davidtwco bf76ffe
Corrected error output with many labels.
davidtwco a1d55be
Fixed bug with the implementation that was suppressing expected error…
davidtwco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So @arielb1 pointed out that there is a risk here. The calls to
access_lvalue
are not guaranteed to report an error -- and, in fact, DROP will report errors in a broader set of conditions thanStorageDead
(I think strictly broader). So it would be better to populate the map (and hence skip the latter check) only if an error was actually reported.What @arielb1 suggested was issuing precisely the same error message in both cases, and letting rustc deduplicate (which it will do). That's an option, though I don't think it's the best path, since I think that the error messages should perhaps be different between the two cases.
Alternatively, we could make
access_lvalue
return a boolean or something, indicating whether an error was reported, and then do:It would also be good to comment about this. =)
It's hard to come up with a test case that would necesarily show off this problem though -- specifically,
Drop
will always come beforeStorageDead
, and hence I imagine we'll visit it first, so the bug won't show itself. But I wouldn't want to rely on that.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've modified what was there based on this, should be fine now.