rust/tests/ui/borrowck/issue-58776-borrowck-scans-children.rs
Giacomo Pasini b3a47d9b6b
Desugars drop and replace at MIR build
This commit desugars the drop and replace deriving from an
assignment at MIR build, avoiding the construction of the
DropAndReplace terminator (which will be removed in a followign PR)

In order to retain the same error messages for replaces a new
DesugaringKind::Replace variant is introduced.
2023-03-03 16:33:11 +01:00

11 lines
239 B
Rust

fn main() {
let mut greeting = "Hello world!".to_string();
let res = (|| (|| &greeting)())();
greeting = "DEALLOCATED".to_string();
//~^ ERROR cannot assign
drop(greeting);
println!("thread result: {:?}", res);
}