diff options
| author | bors <bors@rust-lang.org> | 2018-01-23 22:50:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-23 22:50:03 +0000 |
| commit | fdecb0564b86f6876124903a05e590e929532039 (patch) | |
| tree | 43c76783e6e057c2dba16a711bc03348b0b6826b /src/rustllvm/PassWrapper.cpp | |
| parent | 4e3901d35f6a8652f67111e7272263c9e62ab3e1 (diff) | |
| parent | 55c6c88782cfcce9b593c431200dad5f05bd9125 (diff) | |
| download | rust-fdecb0564b86f6876124903a05e590e929532039.tar.gz rust-fdecb0564b86f6876124903a05e590e929532039.zip | |
Auto merge of #45337 - Zoxc:gen-static, r=nikomatsakis
Immovable generators
This adds support for immovable generators which allow you to borrow local values inside generator across suspension points. These are declared using a `static` keyword:
```rust
let mut generator = static || {
let local = &Vec::new();
yield;
local.push(0i8);
};
generator.resume();
// ERROR moving the generator after it has resumed would invalidate the interior reference
// drop(generator);
```
Region inference is no longer affected by the types stored in generators so the regions inside should be similar to other code (and unaffected by the presence of `yield` expressions). The borrow checker is extended to pick up the slack so interior references still result in errors for movable generators. This fixes #44197, #45259 and #45093.
This PR depends on [PR #44917 (immovable types)](https://github.com/rust-lang/rust/pull/44917), I suggest potential reviewers ignore the first commit as it adds immovable types.
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
