Repository navigation
Skip ignorable places when gathering Reborrow loans - #166070
Open
Dnreikronos wants to merge 3 commits into
Open
Dnreikronos wants to merge 3 commits into
Dnreikronos wants to merge 3 commits into
Conversation
Rvalue::Ref already skips places that ignore_borrow covers, and the Borrows dataflow skips them for both Ref and Reborrow. Reborrow still recorded the loan, so a reborrow through a shared reference left a loan that places_conflict does not expect to see.
Collaborator
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #165604
This was an ICE in borrowck when you reborrow a
Reborrowtype through a shared reference, something likelet b = &a; reborrow(*b);. Instead of the normal "cannot borrow as mutable" error the compiler just crashed.When the borrow set gets built, the
Rvalue::Refpath already skips places thatignore_borrowsays we don't care about, like stuff behind a shared ref. TheBorrowsdataflow skips them too, for bothRefandReborrow. But theReborrowarm never did that check, so it still recorded a loan, and laterplaces_conflictran into a loan it wasn't expecting and panicked.So the fix is just doing the same
ignore_borrowcheck forReborrowthatRefalready does. I went this way because it makes both paths act the same, and I'd rather not teachplaces_conflictabout a case that shouldn't get there in the first place.I added two tests. One is the exclusive reborrow from the issue, which now gives E0596 like you'd expect. The other is
CoerceSharedthrough a shared reference, which should still compile fine, and I wanted to be sure skipping the loan didn't break that.Honestly I thought this would need a bigger change, but once I saw the
Refarm already had the check it felt pretty clearReborrowjust missed it. If someone who knows this code better thinks there's another spot with the same gap, happy to look at it.