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

@@ -2162,7 +2162,8 @@ impl<'a> State<'a> {
}
self.bclose_(expr.span, INDENT_UNIT)?;
}
ast::ExprKind::Closure(capture_clause, ref decl, ref body, _) => {
ast::ExprKind::Closure(capture_clause, movability, ref decl, ref body, _) => {
self.print_movability(movability)?;
self.print_capture_clause(capture_clause)?;
self.print_fn_block_args(decl)?;
@@ -2777,6 +2778,14 @@ impl<'a> State<'a> {
}
}
pub fn print_movability(&mut self, movability: ast::Movability)
-> io::Result<()> {
match movability {
ast::Movability::Static => self.word_space("static"),
ast::Movability::Movable => Ok(()),
}
}
pub fn print_capture_clause(&mut self, capture_clause: ast::CaptureBy)
-> io::Result<()> {
match capture_clause {