diff options
| author | bors <bors@rust-lang.org> | 2014-01-09 16:11:18 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-09 16:11:18 -0800 |
| commit | ff3d5d460399070f660f5a59855fbb4698c797ee (patch) | |
| tree | 6ec333e4e6eb9e153e79bc4a325c9a440ea4c2c2 /src/libsyntax/parse/parser.rs | |
| parent | d28317d78f09d7658c8928b2ff27c6f2ce60b5a4 (diff) | |
| parent | e12711540a00ded4021250f7b2a31773fc4dc734 (diff) | |
| download | rust-ff3d5d460399070f660f5a59855fbb4698c797ee.tar.gz rust-ff3d5d460399070f660f5a59855fbb4698c797ee.zip | |
auto merge of #11055 : pcwalton/rust/placement-box, r=pcwalton
r? @nikomatsakis
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 149b7c1cf18..0424c71dd59 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -23,7 +23,7 @@ use ast::{BlockCheckMode, UnBox}; use ast::{Crate, CrateConfig, Decl, DeclItem}; use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; -use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock}; +use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox}; use ast::{ExprBreak, ExprCall, ExprCast, ExprDoBody}; use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex}; use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac}; @@ -2321,6 +2321,20 @@ impl Parser { token::IDENT(_, _) if self.is_keyword(keywords::Box) => { self.bump(); + // Check for a place: `box(PLACE) EXPR`. + if self.eat(&token::LPAREN) { + // Support `box() EXPR` as the default. + if !self.eat(&token::RPAREN) { + let place = self.parse_expr(); + self.expect(&token::RPAREN); + let subexpression = self.parse_prefix_expr(); + hi = subexpression.span.hi; + ex = ExprBox(place, subexpression); + return self.mk_expr(lo, hi, ex); + } + } + + // Otherwise, we use the unique pointer default. let subexpression = self.parse_prefix_expr(); hi = subexpression.span.hi; // HACK: turn `box [...]` into a boxed-evec |
