rust-lang/rustfix

cargo fix fails on non_shorthand_field_patterns

moxian opened this issue · 0 comments

(Moved from rust-lang/rust#66434)

Code:

#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(unused_mut)]
// #![allow(non_shorthand_field_patterns)]  // uncommenting this removes the bug

struct Some {
    inner: Vec<i32>
}

fn stuff(x: Some){
    let Some {
        inner: inner,
    } =  x;
}


fn main() {
}

cargo fix output:

PS D:\work\trash\repros\some-palette> cargo fix --allow-dirty
    Checking some-palette v0.1.0 (D:\work\trash\repros\some-palette)
warning: failed to automatically apply fixes suggested by rustc to crate `some_palette`

after fixes were automatically applied the compiler reported errors within these files:

  * src\main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error: expected `,`
  --> src\main.rs:12:9
   |
12 |         inner inner,
   |         ^^^^^

error: aborting due to previous error

Original diagnostics will follow.

warning: the `inner:` in this pattern is redundant
  --> src\main.rs:12:9
   |
12 |         inner: inner,
   |         ------^^^^^^
   |         |
   |         help: remove this
   |
   = note: `#[warn(non_shorthand_field_patterns)]` on by default

warning: the `inner:` in this pattern is redundant
  --> src\main.rs:12:9
   |
12 |         inner: inner,
   |         ------^^^^^^
   |         |
   |         help: remove this
   |
   = note: `#[warn(non_shorthand_field_patterns)]` on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.43s

Note that inner inner in the attempted fix is incorrect syntax (it ate a colon).

Version info:

> cargo --version
cargo 1.40.0-beta (5da4b4d47 2019-10-28)
> rustc --version
rustc 1.40.0-beta.1 (76b40532a 2019-11-05)