-
Notifications
You must be signed in to change notification settings - Fork 13.3k
MIR-borrowck: ICE: could not find BorrowIndexs for region scope #44828
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
Transcription of relevant tests according to the discrepancy spreadsheet. (caveat: data is based on out-of-date pnkfelix/mir-borrowck4 branch)
|
I am going to focus on this bug. |
Hmm. Well, it was not hard to address the const-promoted case, but it turns out that is not the only case where this issue is arising. In particular, the test borrowck-assign-to-andmut-in-borrowed-loc.rs generates the following MIR:
The problem that I can see in the above MIR is that the region denoted by Was this an oversight in the borrows-dataflow? Should casts to a type have "gen-bits" for all the regions that appear in the target type? Update: On further reflection the latter suggestion does not seem to make all that much sense. At the very least, the borrows-dataflow is meant to track the actual kind and location of the borrow ... but the regions at the surface of a type do not necessarily map back to any specific borrow that we can see at this point in the analysis. |
Had discussion with @arielb1 (transcribed in details below) who convinced me the right direction here is to remove the assert (and skip attempting to update the flow state in these cases).
|
some dataflow-tracked borrow-data entry. Fix rust-lang#44828 (The comment thread on the aforementioned issue discusses why its best to just remove this assertion.)
For the record, the case we found was this: rust/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs Lines 1 to 31 in 67ed489
|
…exes-ice, r=arielb1 `EndRegion` do not always correspond to borrow-data entries Remove assertion that the argument to every `EndRegion` correspond to some dataflow-tracked borrow-data entry. Fix rust-lang#44828 (The comment thread on the aforementioned issue discusses why its best to just remove this assertion.)
There are many tests in
compile-fail/borrowck/
that ICE with the same failure: "could not findBorrowIndexes
for region scope ..."My suspicion is that all of these are arising due to dataflow attempting to look up a region in a const-promoted MIR fragment (e.g. for the body of a closure is the common case, I think). Before promotion the MIR in question had references to regions that actually corresponded to some borrow within the same MIR. (And originally MIR-borrowck was running before const-promotion, which is why I did not address the problem during the original development.)
But someone should of course confirm the above hypothesis.
Assuming that hypothesis holds, the next step would be to actually fix the problem in some reasonable way. One way would be to rewrite the MIR during promotion, replacing the regions in question. But another, probably simpler (and more efficient) way to fix this could be to just make the dataflow code assume that such regions always correspond to something that spans the entirety of the MIR being analyzed. (That fix definitely requires that we confirm the above hypothesis is the only reason this ICE is arising.)
The text was updated successfully, but these errors were encountered: