diff options
| author | Kevin Ballard <kevin@sb.org> | 2014-08-27 21:34:03 -0700 |
|---|---|---|
| committer | Jakub Wieczorek <jakub@jakub.cc> | 2014-09-30 18:54:03 +0200 |
| commit | 13e00e4a3d18802ca6407e59935be9f2c33ec061 (patch) | |
| tree | 86310bd54230b0caaa201dbf7485e104abe935f2 /src/libsyntax | |
| parent | 8a609521007c0c0c37d8d2396085631c08ad5232 (diff) | |
| download | rust-13e00e4a3d18802ca6407e59935be9f2c33ec061.tar.gz rust-13e00e4a3d18802ca6407e59935be9f2c33ec061.zip | |
Update based on PR feedback
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 36 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 |
3 files changed, 20 insertions, 22 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index de6a8675e13..76ca33cc2b8 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -132,26 +132,22 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> { } // Desugar support for ExprIfLet in the ExprIf else position - ast::ExprIf(cond, blk, mut elseopt) => { - // NOTE: replace with 'if let' after snapshot - match elseopt { - Some(els) => match els.node { - ast::ExprIfLet(..) => { - // wrap the if-let expr in a block - let blk = P(ast::Block { - view_items: vec![], - stmts: vec![], - expr: Some(els), - id: ast::DUMMY_NODE_ID, - rules: ast::DefaultBlock, - span: els.span - }); - elseopt = Some(fld.cx.expr_block(blk)); - } - _ => () - }, - None => () - }; + ast::ExprIf(cond, blk, elseopt) => { + let elseopt = elseopt.map(|els| match els.node { + ast::ExprIfLet(..) => { + // wrap the if-let expr in a block + let blk = P(ast::Block { + view_items: vec![], + stmts: vec![], + expr: Some(els), + id: ast::DUMMY_NODE_ID, + rules: ast::DefaultBlock, + span: els.span + }); + fld.cx.expr_block(blk) + } + _ => els + }); let if_expr = fld.cx.expr(e.span, ast::ExprIf(cond, blk, elseopt)); noop_fold_expr(if_expr, fld) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index fac4244228a..ca6d488772c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -360,7 +360,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { } ast::ExprIfLet(..) => { self.gate_feature("if_let", e.span, - "`if let` desugaring is experimental"); + "`if let` syntax is experimental"); } _ => {} } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ccb398bf2fb..0780e68a062 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -579,7 +579,9 @@ impl<'a> Parser<'a> { if self.is_keyword(kw) { self.bump(); true - } else { false } + } else { + false + } } /// If the given word is not a keyword, signal an error. |
