Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dtolnay opened this issue Nov 19, 2020 · 2 comments · Fixed by #4536
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@dtolnay
Copy link
Member

dtolnay commented Nov 19, 2020

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
@dtolnay dtolnay added the bug Panic, non-idempotency, invalid code, etc. label Nov 19, 2020
@dtolnay dtolnay changed the title Rustfmt produces duplicated subexpressions and unparseable output involving as casts Rustfmt regression: produces duplicated subexpressions and unparseable output involving as casts Nov 19, 2020
@calebcartwright
Copy link
Member

Yikes, bad span derivation. One sec will post a fix

@calebcartwright
Copy link
Member

Thanks for the report and the detailed investigation. My apologies on this one, did not pay close enough attention to the spans in the review 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
2 participants