Auto merge of #44480 - Zoxc:gen-liveness, r=arielb1
Analyse storage liveness and preserve it during generator transformation This uses a dataflow analysis on `StorageLive` and `StorageDead` statements to infer where the storage of locals are live. The result of this analysis is intersected with the regular liveness analysis such that a local is can only be live when its storage is. This fixes https://github.com/rust-lang/rust/issues/44184. If the storage of a local is live across a suspension point, we'll insert a `StorageLive` statement for it after the suspension point so storage liveness is preserved. This fixes https://github.com/rust-lang/rust/issues/44179. r? @arielb1
This commit is contained in:
commit
5dfc84cfa7
7 changed files with 354 additions and 174 deletions
30
src/test/run-pass/generator/match-bindings.rs
Normal file
30
src/test/run-pass/generator/match-bindings.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(generators)]
|
||||
|
||||
enum Enum {
|
||||
A(String),
|
||||
B
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|| {
|
||||
loop {
|
||||
if let true = true {
|
||||
match Enum::A(String::new()) {
|
||||
Enum::A(_var) => {}
|
||||
Enum::B => {}
|
||||
}
|
||||
}
|
||||
yield;
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue