Auto merge of #61872 - matthewjasper:refactor-mir-drop-gen, r=nikomatsakis
Clean up MIR drop generation * Don't assign twice to the destination of a `while` loop containing a `break` expression * Use `as_temp` to evaluate statement expression * Avoid consecutive `StorageLive`s for the condition of a `while` loop * Unify `return`, `break` and `continue` handling, and move it to `scopes.rs` * Make some of the `scopes.rs` internals private * Don't use `Place`s that are always `Local`s in MIR drop generation Closes #42371 Closes #61579 Closes #61731 Closes #61834 Closes #61910 Closes #62115
This commit is contained in:
commit
d3e2cec292
27 changed files with 536 additions and 468 deletions
32
src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs
Normal file
32
src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Test that we don't consider temporaries for statement expressions as live
|
||||
// across yields
|
||||
|
||||
// check-pass
|
||||
// edition:2018
|
||||
|
||||
#![feature(async_await, generators, generator_trait)]
|
||||
|
||||
use std::ops::Generator;
|
||||
|
||||
async fn drop_and_await() {
|
||||
async {};
|
||||
async {}.await;
|
||||
}
|
||||
|
||||
fn drop_and_yield() {
|
||||
let x = || {
|
||||
String::new();
|
||||
yield;
|
||||
};
|
||||
Box::pin(x).as_mut().resume();
|
||||
let y = static || {
|
||||
String::new();
|
||||
yield;
|
||||
};
|
||||
Box::pin(y).as_mut().resume();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
drop_and_await();
|
||||
drop_and_yield();
|
||||
}
|
||||
11
src/test/ui/nll/assign-while-to-immutable.rs
Normal file
11
src/test/ui/nll/assign-while-to-immutable.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// We used to incorrectly assign to `x` twice when generating MIR for this
|
||||
// function, preventing this from compiling.
|
||||
|
||||
// check-pass
|
||||
|
||||
fn main() {
|
||||
let x = while false {
|
||||
break;
|
||||
};
|
||||
let y = 'l: while break 'l {};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue