From 475bb383c958962dee984cf4086b4ec341c3d10e Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 15 May 2019 16:04:12 +0200 Subject: [PATCH 01/15] let_chains: Remove ast::ExprKind::{IfLet, WhileLet} and introduce ::Let. --- src/libsyntax/ast.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index d12240655e628..61b1f9be8fe72 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1049,10 +1049,9 @@ impl Expr { ExprKind::Unary(..) => ExprPrecedence::Unary, ExprKind::Lit(_) => ExprPrecedence::Lit, ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast, + ExprKind::Let(..) => ExprPrecedence::Let, ExprKind::If(..) => ExprPrecedence::If, - ExprKind::IfLet(..) => ExprPrecedence::IfLet, ExprKind::While(..) => ExprPrecedence::While, - ExprKind::WhileLet(..) => ExprPrecedence::WhileLet, ExprKind::ForLoop(..) => ExprPrecedence::ForLoop, ExprKind::Loop(..) => ExprPrecedence::Loop, ExprKind::Match(..) => ExprPrecedence::Match, @@ -1135,26 +1134,17 @@ pub enum ExprKind { Cast(P, P), /// A type ascription (e.g., `42: usize`). Type(P, P), + /// A `let pat = expr` pseudo-expression that only occurs in the scrutinee + /// of `if` / `while` expressions. (e.g., `if let 0 = x { .. }`). + Let(Vec>, P), /// An `if` block, with an optional `else` block. /// /// `if expr { block } else { expr }` If(P, P, Option>), - /// An `if let` expression with an optional else block - /// - /// `if let pat = expr { block } else { expr }` - /// - /// This is desugared to a `match` expression. - IfLet(Vec>, P, P, Option>), - /// A while loop, with an optional label + /// A while loop, with an optional label. /// /// `'label: while expr { block }` While(P, P, Option