From 8cf35643106bba09b5d6c71ceac74dc58573f371 Mon Sep 17 00:00:00 2001 From: Fabian Zaiser Date: Wed, 11 Nov 2020 13:15:15 +0000 Subject: Add underscore expressions for destructuring assignments Co-authored-by: varkor --- compiler/rustc_parse/src/parser/expr.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 188bf227c42..ffbf786491d 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1089,6 +1089,9 @@ impl<'a> Parser<'a> { self.parse_yield_expr(attrs) } else if self.eat_keyword(kw::Let) { self.parse_let_expr(attrs) + } else if self.eat_keyword(kw::Underscore) { + self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span); + Ok(self.mk_expr(self.prev_token.span, ExprKind::Underscore, attrs)) } else if !self.unclosed_delims.is_empty() && self.check(&token::Semi) { // Don't complain about bare semicolons after unclosed braces // recovery in order to keep the error count down. Fixing the -- cgit 1.4.1-3-g733a5