From a63003fe1aac487d3c0c527c4c984375c998de99 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 23 Jul 2014 12:43:29 -0700 Subject: librustc: Parse, but do not fully turn on, the `ref` keyword for by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12381. --- src/libsyntax/print/pprust.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/print') diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9d4b7343c8a..3ef9d96e3b6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1437,7 +1437,9 @@ impl<'a> State<'a> { } try!(self.bclose_(expr.span, indent_unit)); } - ast::ExprFnBlock(ref decl, ref body) => { + ast::ExprFnBlock(capture_clause, ref decl, ref body) => { + try!(self.print_capture_clause(capture_clause)); + // in do/for blocks we don't want to show an empty // argument list, but at this point we don't know which // we are inside. @@ -1467,7 +1469,9 @@ impl<'a> State<'a> { // empty box to satisfy the close. try!(self.ibox(0)); } - ast::ExprUnboxedFn(ref decl, ref body) => { + ast::ExprUnboxedFn(capture_clause, ref decl, ref body) => { + try!(self.print_capture_clause(capture_clause)); + // in do/for blocks we don't want to show an empty // argument list, but at this point we don't know which // we are inside. @@ -2030,6 +2034,14 @@ impl<'a> State<'a> { self.maybe_print_comment(decl.output.span.lo) } + pub fn print_capture_clause(&mut self, capture_clause: ast::CaptureClause) + -> IoResult<()> { + match capture_clause { + ast::CaptureByValue => Ok(()), + ast::CaptureByRef => self.word_space("ref"), + } + } + pub fn print_proc_args(&mut self, decl: &ast::FnDecl) -> IoResult<()> { try!(word(&mut self.s, "proc")); try!(word(&mut self.s, "(")); -- cgit 1.4.1-3-g733a5