cargo fix fails on non_shorthand_field_patterns #66434
Closed
Description
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).
Github helpfully suggests that #65924 might be related. Edit: it probably actually isn't.
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)
Metadata
Assignees
Labels
Area: Lints (warnings about flaws in source code) such as unused_mut.Area: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: A structured suggestion resulting in incorrect code.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity