Adds support for immovable generators. Move checking of invalid borrows across suspension points to borrowck. Fixes #44197, #45259 and #45093.

This commit is contained in:
John Kåre Alsaker
2017-10-07 16:36:28 +02:00
parent 47a8eb7c4e
commit ccf0d8399e
60 changed files with 863 additions and 213 deletions

View File

@@ -1100,7 +1100,7 @@ pub enum ExprKind {
/// A closure (for example, `move |a, b, c| a + b + c`)
///
/// The final span is the span of the argument block `|...|`
Closure(CaptureBy, P<FnDecl>, P<Expr>, Span),
Closure(CaptureBy, Movability, P<FnDecl>, P<Expr>, Span),
/// A block (`{ ... }`)
Block(P<Block>),
/// A catch block (`catch { ... }`)
@@ -1194,6 +1194,13 @@ pub enum CaptureBy {
Ref,
}
/// The movability of a generator / closure literal
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum Movability {
Static,
Movable,
}
pub type Mac = Spanned<Mac_>;
/// Represents a macro invocation. The Path indicates which macro