about summary refs log tree commit diff
path: root/src/librustc_trans
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-01-23 22:50:03 +0000
committerbors <bors@rust-lang.org>2018-01-23 22:50:03 +0000
commitfdecb0564b86f6876124903a05e590e929532039 (patch)
tree43c76783e6e057c2dba16a711bc03348b0b6826b /src/librustc_trans
parent4e3901d35f6a8652f67111e7272263c9e62ab3e1 (diff)
parent55c6c88782cfcce9b593c431200dad5f05bd9125 (diff)
downloadrust-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/librustc_trans')
-rw-r--r--src/librustc_trans/debuginfo/type_names.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs
index 0aec92b0d66..6490d109f29 100644
--- a/src/librustc_trans/debuginfo/type_names.rs
+++ b/src/librustc_trans/debuginfo/type_names.rs
@@ -173,6 +173,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         ty::TyInfer(_) |
         ty::TyProjection(..) |
         ty::TyAnon(..) |
+        ty::TyGeneratorWitness(..) |
         ty::TyParam(_) => {
             bug!("debuginfo: Trying to create type name for \
                 unexpected type: {:?}", t);