Skip to content

Rustfmt regression: produces duplicated subexpressions and unparseable output involving as casts #4534

Closed
@dtolnay

Description

@dtolnay

Bisects to 6646248 (#4406).

To reproduce:

$ echo 'fn main() { let z = (x as f64 / y as f64).floor() as usize; }' | CFG_RELEASE_CHANNEL=dev CFG_RELEASE=1.48.0 cargo +nightly-2020-09-16 run --bin rustfmt --features rustfmt

Against the parent commit of 6646248 (correct output):

fn main() {
    let z = (x as f64 / y as f64).floor() as usize;
}

Against 6646248, and all the way through current master (17d90ca as of filing):

fn main() {
    let z = (x as f64 / y as f64).floor() as f64 / y as f64).floor()
        as f64 / y as f64).floor() as usize;
}
error: unexpected closing delimiter: `)`
 --> src/main.rs:3:26
  |
3 |         as f64 / y as f64).floor() as usize;
  |                          ^ unexpected closing delimiter

error: mismatched closing delimiter: `)`
 --> src/main.rs:2:60
  |
1 | fn main() {
  |           - unclosed delimiter
2 |     let z = (x as f64 / y as f64).floor() as f64 / y as f64).floor()
  |                                                            ^ mismatched closing delimiter

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions