-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use of unimplemented!() causing ICE with NLL #52058
Conversation
None, | ||
"never found an activation for this borrow!", | ||
); | ||
|
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 am a bit concerned here because I don't know where two-phase borrows that wind up unactivated will be set to TwoPhaseActivation::NotActivated
. I think they will erroneously be recorded as not two phase. This means we will get an error with e.g. this code:
fn main() {
let mut vec = vec![];
vec.push((vec.len(), panic!()));
}
I expect this to error because the borrow of vec
for calling push
will incorrectly be considered "not two phase".
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.
To fix this, I think we can modify insert_as_pending_if_two_phase
to set the activation_location
field to NotActivated
instead of NotTwoPhase
. Then when we do find an activation we can assert that the field is "not activated".
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.
If I am correct about all this btw please add that above test. =)
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.
Pushed a commit that addresses this.
@@ -237,6 +237,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> { | |||
TwoPhaseActivation::NotActivated | |||
} | |||
_ => { | |||
// Double check: We should have found an activation for every pending |
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 think this commit is not quite correct -- that is, what we are checking here is that (a) this is indeed a 2-phase borrow and (b) we've not found some other activation (though we also check that above), right?
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.
Pushed improved comments.
@@ -322,6 +330,10 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> { | |||
); | |||
}; | |||
|
|||
// Consider the borrow not activated. |
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'd say "Consider the borrow not activated to start. When we find an activation, we'll update this field."
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.
Pushed improved comments.
@bors r+ |
📌 Commit f90eada has been approved by |
Use of unimplemented!() causing ICE with NLL Fixes rust-lang#51345. r? @nikomatsakis
Rollup of 9 pull requests Successful merges: - #51901 (Rc: remove unused allocation and fix segfault in Weak::new()) - #52058 (Use of unimplemented!() causing ICE with NLL) - #52067 (Visit the mir basic blocks in reverse-postfix order) - #52083 (Dont run ast borrowck on mir mode) - #52099 (fix typo in stable `--edition` error message) - #52103 (Stabilize rc_downcast) - #52104 (Remove unnecessary feature gate.) - #52117 (Dedupe filetime) - #52120 (ARM: expose the "mclass" target feature) Failed merges: r? @ghost
Fixes #51345.
r? @nikomatsakis