diff options
| author | nx2k3 <nx2k3@duck.com> | 2023-02-27 16:54:38 +0000 |
|---|---|---|
| committer | nx2k3 <nx2k3@duck.com> | 2023-02-27 17:31:55 +0000 |
| commit | a4830266b01465462aab352008b2720ac60f2213 (patch) | |
| tree | 933cce19290f0de4c8423fefeeecca34fd066380 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 0883973d2a1a0346832e1d8556997f771c87e5d7 (diff) | |
| download | rust-a4830266b01465462aab352008b2720ac60f2213.tar.gz rust-a4830266b01465462aab352008b2720ac60f2213.zip | |
handle only postfix decrement
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index d1dc4ce1e99..ec50388cb46 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -561,10 +561,10 @@ impl<'a> Parser<'a> { token::Not => make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Not)), // `~expr` token::Tilde => make_it!(this, attrs, |this, _| this.recover_tilde_expr(lo)), - // // `-expr` - // token::BinOp(token::Minus) => { - // make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Neg)) - // } + // `-expr` + token::BinOp(token::Minus) => { + make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Neg)) + } // `*expr` token::BinOp(token::Star) => { make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Deref)) @@ -606,27 +606,7 @@ impl<'a> Parser<'a> { let operand_expr = this.parse_dot_or_call_expr(Default::default())?; this.recover_from_prefix_increment(operand_expr, pre_span, starts_stmt) } - // Recover from `--x`: - token::BinOp(token::Minus) - if this.look_ahead(1, |t| *t == token::BinOp(token::Minus)) - && !this.token.can_begin_expr() => - { - let starts_stmt = this.prev_token == token::Semi - || this.prev_token == token::CloseDelim(Delimiter::Brace); - let pre_span = this.token.span.to(this.look_ahead(1, |t| t.span)); - // if !this.token.can_begin_expr() { - // Eat both `-`s. - this.bump(); - this.bump(); - let operand_expr = this.parse_dot_or_call_expr(Default::default())?; - this.recover_from_prefix_decrement(operand_expr, pre_span, starts_stmt) - // } - } - // `-expr` - token::BinOp(token::Minus) => { - make_it!(this, attrs, |this, _| this.parse_unary_expr(lo, UnOp::Neg)) - } token::Ident(..) if this.token.is_keyword(kw::Box) => { make_it!(this, attrs, |this, _| this.parse_box_expr(lo)) } |
