-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)
Description
When assigning a non-Copy
field of a structure which has a destructor, the drop of the field before writing the new value causes a warning in the MIR dataflow code:
struct Foo(String);
impl Drop for Foo {
fn drop(&mut self) {}
}
fn main() {
let mut f = Foo(String::from("foo"));
f.0 = String::from("bar");
}
test.rs:8:9: 8:14 warning: dataflow bug??? moving out of type with dtor DropCtxt { span: test.rs:8:9: 8:14, scope: ScopeId(3), is_cleanup: true, init_data: , lvalue: var0, path: MovePathIndex(NonZero(1)), succ: bb1, unwind: None }
test.rs:8 let mut f = Foo(String::from("foo"));
^~~~~
Seeing how this is supported in stable Rust, the warning seems superfluous and the resulting code runs without a hitch, although I'm not sure if there any subtle problems around unwinding.
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)