-
Notifications
You must be signed in to change notification settings - Fork 13.3k
MIR-borrowck: identify cause of (and fix) extra "move out"/"assign to" errors signalled by mir-borrowck #44832
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
(Incomplete list of) relevant tests according to the discrepancy spreadsheet. (caveat: data is based on out-of-date pnkfelix/mir-borrowck4 branch)
|
I would like to attempt to fix this if that's cool. I would like to just known if this is a single test or part of the main Rust test suite this bug is hitting. Seems this line is in all three: |
@xerofoify asked:
You cannot assign You can assign a
|
@xerofoify there may be easier issues to start in on if this is your first foray into hacking on the borrow checking code. In particular, a narrow test failure like this one where mir-borrowck isn't handling FRU correctly #44833 might be a good initial bug. Having said that, I'm happy to advise on any bug you want to dive in on. Feel free to join us in the gitter channel for NLL (which encompasses the mir-borrowck work for now): https://gitter.im/rust-impl-period/WG-compiler-nll |
I looked a little bit into this tonight, for the specific case of Below is the MIR (in the
And, here is the line from RUST_LOG (with some line breaks added by hand for presentation purposes), right before we emit the extraneous error, along with the error itself:
Two things of interest.
I think point 2 is the bigger bug of interest here. Figuring out what's happening there might resolve a lot of these extraneous E0505 emissions that I am seeing from MIR-borrowck. |
Okay so next step: I made a copy of #![feature(rustc_attrs)]
#[rustc_mir(borrowck_graphviz_preflow="preflow.dot",
borrowck_graphviz_postflow="postflow.dot")] This special attribute tells the compiler to dump dot files summarizing the dataflow state (both before and after running the flow). From the generated In particular, the control flow path bb0 -> bb1 -> bb4 -> bb3 is the problematic one. bb0 creates the borrow, then we assume a normal return to bb1, then during the drop there we allow for a fault that causes us to unwind to bb4 which falls through to bb3 and we hit our problematic drop.
|
Okay I think I am on the road to fixing this. Namely, I have a local branch that modifies we emit I believe this local branch will fix at least the following cases:
|
I have a fix for this in a local branch |
Improves rust-lang#44832 borrowck-overloaded-index-move-index.rs - fixed borrowck-multiple-captures.rs - still ICE borrowck-issue-2657-1.rs - fixed borrowck-loan-blocks-move.rs - fixed borrowck-move-from-subpath-of-borrowed-path.rs - fixed borrowck-mut-borrow-linear-errors.rs - still ICE borrowck-no-cycle-in-exchange-heap.rs - fixed borrowck-unary-move.rs - fixed borrowck-loan-blocks-move-cc.rs - fixed borrowck-vec-pattern-element-loan.rs - still broken
Note: the |
There are many tests in
compile-fail/borrowck/
that, in addition to signalling the errors that we already expect, also include a number of additional errors usually of the form "cannot move out of because it is borrowed.".You can see list of such tests in the discrepancy spreadsheet.
Here is example output from an especially bad instance of the problem:
These errors often (perhaps always?) occur at the end of some lexical scope, so perhaps they are arising due to over-zealous handling of destructors, or
StorageDead
(orEndRegion
)?In any case, they represent a lot of extra noise and need to be dealt with.
The text was updated successfully, but these errors were encountered: