diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-03 10:40:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-03 10:40:57 +0100 |
| commit | 9aff9c070ae51ff50ff67781ede596109b1f6b5d (patch) | |
| tree | 5818ea274514517495181a9e173510700c0cd5f1 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 2344a34241e2cf08e6285ddf7755b70bfa306e5a (diff) | |
| parent | 462604d8256348901e042ad0de600c76d4c8d029 (diff) | |
| download | rust-9aff9c070ae51ff50ff67781ede596109b1f6b5d.tar.gz rust-9aff9c070ae51ff50ff67781ede596109b1f6b5d.zip | |
Rollup merge of #134900 - dtolnay:unoprange, r=compiler-errors,davidtwco
Fix parsing of ranges after unary operators Fixes https://github.com/rust-lang/rust/issues/134899. This PR aligns the parsing for unary `!` and `-` and `*` with how unary `&` is already parsed [here](https://github.com/rust-lang/rust/blob/5c0a6e68cfdad859615c2888de76505f13e6f01b/compiler/rustc_parse/src/parser/expr.rs#L848-L854).
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index ef29ac2719d..d93f8c4b103 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -567,7 +567,11 @@ impl<'a> Parser<'a> { fn parse_expr_prefix_common(&mut self, lo: Span) -> PResult<'a, (Span, P<Expr>)> { self.bump(); let attrs = self.parse_outer_attributes()?; - let expr = self.parse_expr_prefix(attrs)?; + let expr = if self.token.is_range_separator() { + self.parse_expr_prefix_range(attrs) + } else { + self.parse_expr_prefix(attrs) + }?; let span = self.interpolated_or_expr_span(&expr); Ok((lo.to(span), expr)) } |
