Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

cargo fix fails on non_shorthand_field_patterns #181

Closed
moxian opened this issue Nov 15, 2019 · 0 comments
Closed

cargo fix fails on non_shorthand_field_patterns #181

moxian opened this issue Nov 15, 2019 · 0 comments

Comments

@moxian
Copy link

moxian commented Nov 15, 2019

(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)
@moxian moxian closed this as completed Nov 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant