Description
There are many tests in compile-fail/borrowck/
that ICE with the same failure: "could not find BorrowIndexes
for region scope ..."
- You can see list of such tests in the discrepancy spreadsheet.
- But for ease of reference, I am also transcribing that list into the first comment on this issue.
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.)