diff options
| author | David Tolnay <dtolnay@gmail.com> | 2024-12-27 18:43:05 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-27 18:43:05 -0800 |
| commit | 3fc0f08b8988e8864effd2ccaa6187df524e892e (patch) | |
| tree | dd392a797a32bb1a90d49d2938eb3e5a2bff40ca /compiler/rustc_codegen_llvm/src | |
| parent | 2d96f2a48fb825e2028c1ee45f3a4ebd941ff8e2 (diff) | |
| parent | e67fe3698bfd0f3957abb84c2b396c50822a5b67 (diff) | |
| download | rust-3fc0f08b8988e8864effd2ccaa6187df524e892e.tar.gz rust-3fc0f08b8988e8864effd2ccaa6187df524e892e.zip | |
Rollup merge of #134833 - dtolnay:leftmostwithdot, r=compiler-errors
Skip parenthesis if `.` makes statement boundary unambiguous
There is a rule in the parser that statements and match-arms never end in front of a `.` or `?` token (except when the `.` is really `..` or `..=` or `...`). So some of the leading subexpressions that need parentheses inserted when followed by some other operator like `-` or `+`, do not need parentheses when followed by `.` or `?`.
Example:
```rust
fn main() {
loop {}.to_string() + "";
match () {
_ => loop {}.to_string() + "",
};
}
```
`-Zunpretty=expanded` before:
```console
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn main() {
(loop {}).to_string() + "";
match () { _ => (loop {}).to_string() + "", };
}
```
After:
```console
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn main() {
loop {}.to_string() + "";
match () { _ => loop {}.to_string() + "", };
}
```
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
