diff options
| author | bors <bors@rust-lang.org> | 2020-11-12 23:23:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-12 23:23:56 +0000 |
| commit | e80ee05bfc135d7d800f3fcc89bc005d6858cd9b (patch) | |
| tree | 4b8950bc77d07a409c0c444ac07d6816785eede1 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 9722952f0bed5815cb22cb4878be09fb39f92804 (diff) | |
| parent | 38ca6e3561dbd2465cd604feeed93cf82580745c (diff) | |
| download | rust-e80ee05bfc135d7d800f3fcc89bc005d6858cd9b.tar.gz rust-e80ee05bfc135d7d800f3fcc89bc005d6858cd9b.zip | |
Auto merge of #78998 - m-ou-se:rollup-6r4pt9m, r=m-ou-se
Rollup of 7 pull requests Successful merges: - #76730 (Fix rustdoc rendering of by-value mutable arguments in async fn) - #78836 (Implement destructuring assignment for structs and slices) - #78857 (Improve BinaryHeap performance) - #78950 (Add asm register information for SPIR-V) - #78970 (update rustfmt to v1.4.25) - #78972 (Update cargo) - #78987 (extend min_const_generics param ty tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index c2a13d4b0de..188bf227c42 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2087,7 +2087,7 @@ impl<'a> Parser<'a> { recover: bool, ) -> PResult<'a, P<Expr>> { let mut fields = Vec::new(); - let mut base = None; + let mut base = ast::StructRest::None; let mut recover_async = false; attrs.extend(self.parse_inner_attributes()?); @@ -2102,8 +2102,14 @@ impl<'a> Parser<'a> { while self.token != token::CloseDelim(token::Brace) { if self.eat(&token::DotDot) { let exp_span = self.prev_token.span; + // We permit `.. }` on the left-hand side of a destructuring assignment. + if self.check(&token::CloseDelim(token::Brace)) { + self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span); + base = ast::StructRest::Rest(self.prev_token.span.shrink_to_hi()); + break; + } match self.parse_expr() { - Ok(e) => base = Some(e), + Ok(e) => base = ast::StructRest::Base(e), Err(mut e) if recover => { e.emit(); self.recover_stmt(); |
