From 42accc99e6c4ad83876460afbda9d0adab750930 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 15 May 2019 16:04:12 +0200 Subject: [PATCH 01/35] 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 b1a62ac81d033..4f2fccd20e5f5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1032,10 +1032,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, @@ -1116,26 +1115,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