mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Update based on PR feedback
This commit is contained in:
parent
8a60952100
commit
13e00e4a3d
@ -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.
|
||||
|
@ -1,3 +1,3 @@
|
||||
% The Rust Reference Manual
|
||||
|
||||
The manual has moved, and is now called [the reference](reference.html).
|
||||
The manual has moved, and is now called [the reference](reference.html).
|
||||
|
@ -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, _) => {
|
||||
//
|
||||
|
@ -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));
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user