Before #107844, assignments of Drop types were modeled using replaced the DropAndReplace MIR terminator. That PR changed the behaviour to use a plain Drop followed by a plain Assign.
This made more code compile, for instance (#107844 (comment)):
struct Foo<'a> {
v: &'a mut (),
}
impl Drop for Foo<'_> {
fn drop(&mut self) {}
}
fn bar() {
let mut v = ();
let mut x = Foo { v: &mut v };
drop(x);
x = Foo { v: &mut v };
}
Steps:
Before #107844, assignments of
Droptypes were modeled using replaced theDropAndReplaceMIR terminator. That PR changed the behaviour to use a plainDropfollowed by a plainAssign.This made more code compile, for instance (#107844 (comment)):
Steps: