diff --git a/src/doc/reference.md b/src/doc/reference.md index 04ebcf9a3fb..0500088bbdc 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2441,7 +2441,7 @@ The currently implemented features of the reference compiler are: * `default_type_params` - Allows use of default type parameters. The future of this feature is uncertain. -* `if_let` - Allows use of the `if let` desugaring syntax. +* `if_let` - Allows use of the `if let` syntax. * `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics are inherently unstable and no promise about them is made. diff --git a/src/doc/rust.md b/src/doc/rust.md index c5dd95902fc..7f02260cd2c 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1,3 +1,3 @@ % The Rust Reference Manual -The manual has moved, and is now called [the reference](reference.html). \ No newline at end of file +The manual has moved, and is now called [the reference](reference.html). diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index f370de31fdc..a9a3981ab5f 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -222,7 +222,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { self.add_node(expr.id, [then_exit, else_exit]) // 4, 5 } - ast::ExprIfLet(..) => fail!("non-desugared ExprIfLet"), + ast::ExprIfLet(..) => { + self.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } ast::ExprWhile(ref cond, ref body, _) => { // diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 4423b83c745..51cdbfcf251 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -374,7 +374,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> { } } - ast::ExprIfLet(..) => fail!("non-desugared ExprIfLet"), + ast::ExprIfLet(..) => { + self.tcx().sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } ast::ExprMatch(ref discr, ref arms, _) => { let discr_cmt = return_if_err!(self.mc.cat_expr(&**discr)); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 00e65f34cf3..2176cd56589 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -481,7 +481,9 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) { ir.add_live_node_for_node(expr.id, ExprNode(expr.span)); visit::walk_expr(ir, expr); } - ExprIfLet(..) => fail!("non-desugared ExprIfLet"), + ExprIfLet(..) => { + ir.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } ExprForLoop(ref pat, _, _, _) => { pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| { debug!("adding local variable {} from for loop with bm {:?}", @@ -1012,7 +1014,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&**cond, ln) } - ExprIfLet(..) => fail!("non-desugared ExprIfLet"), + ExprIfLet(..) => { + self.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } ExprWhile(ref cond, ref blk, _) => { self.propagate_through_loop(expr, WhileLoop(&**cond), &**blk, succ) @@ -1473,7 +1477,9 @@ fn check_expr(this: &mut Liveness, expr: &Expr) { ExprPath(..) | ExprBox(..) => { visit::walk_expr(this, expr); } - ExprIfLet(..) => fail!("non-desugared ExprIfLet") + ExprIfLet(..) => { + this.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index d5ada0c5411..115432873ff 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -506,7 +506,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty)) } - ast::ExprIfLet(..) => fail!("non-desugared ExprIfLet") + ast::ExprIfLet(..) => { + self.tcx().sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index b55c3039ac8..5ef058fad35 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3631,10 +3631,13 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { RvalueDpsExpr } + ast::ExprIfLet(..) => { + tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } + ast::ExprLit(ref lit) if lit_is_str(&**lit) => { RvalueDpsExpr } - ast::ExprIfLet(..) => fail!("non-desugared ExprIfLet"), ast::ExprCast(..) => { match tcx.node_types.borrow().find(&(expr.id as uint)) { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 2c866b9ee38..dd7b8a7e624 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -4106,7 +4106,9 @@ fn check_expr_with_unifier(fcx: &FnCtxt, check_then_else(fcx, &**cond, &**then_blk, opt_else_expr.as_ref().map(|e| &**e), id, expr.span, expected); } - ast::ExprIfLet(..) => fail!("non-desugared ExprIfLet"), + ast::ExprIfLet(..) => { + tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet"); + } ast::ExprWhile(ref cond, ref body, _) => { check_expr_has_type(fcx, &**cond, ty::mk_bool()); check_block_no_value(fcx, &**body); 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, fld: &mut MacroExpander) -> P { } // 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.