restore move out dataflow, add report of move out errors#45877
restore move out dataflow, add report of move out errors#45877bors merged 3 commits intorust-lang:masterfrom
Conversation
| &self.describe_lvalue(lvalue), | ||
| Origin::Mir); | ||
| err.span_label(span, format!("value {} here after move", desired_action)); | ||
| for moi in mois { |
There was a problem hiding this comment.
AST borrowck only shows 1 move here, as in:
fn main() {
let x = Box::new(1);
if false {
let _y = x;
} else {
drop(x);
}
x;
}So I think you should only show a note for the first move.
There was a problem hiding this comment.
Also, AST borrowck prefers the "value might be uninitialized" error to the "value might be moved" one - you can get it if you add a "move" representing values being uninitialized at the start of a function to the move-propagation code, but I won't block this PR on not matching the AST error behavior - this is an edge case and both error messages point at real problems.
| sets: &mut BlockSets<MoveOutIndex>, | ||
| location: Location) | ||
| { | ||
| let (mir, move_data) = (self.mir, self.move_data()); |
There was a problem hiding this comment.
this code doesn't account for DropAndReplace - that should be handled the same way as an assignment above, so it would be buggy in the case of e.g.
let x = Box::new(0);
let _u = x; // error shouldn't note this move
x = Box::new(1);
drop(x);
use(x);|
nice PR, r=me modulo comments (you only have to fix the 1-error and the DropAndReplace problems - I'm not sure defaulting to "maybe uninitialized" is actually better). |
|
Actually, could you make it so that the moving-statements pass only runs if an error occurred? This would avoid it slowing down the normal error-free path. |
|
r=me if this is green on travis |
|
@bors r+ rollup |
|
📌 Commit 3acb4e9 has been approved by |
…d, r=arielb1 restore move out dataflow, add report of move out errors fix rust-lang#45363 r? @arielb1
fix #45363
r? @arielb1