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](5c0a6e68cf/compiler/rustc_parse/src/parser/expr.rs (L848-L854)
).
This commit is contained in:
commit
9aff9c070a
2 changed files with 32 additions and 2 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue