Skip to content

cargo fix: tell user why some fixes aren't applied (such as maybe-incorrect) #8806

Open
@tklebanoff

Description

@tklebanoff

Problem

when I run "cargo fix", It completes with no errors, but nothing changes in the source code.

$cargo fix --allow-dirty
Checking my_program v0.1.0 (/Users/user/home/work/repo/my_program)
warning: variant ct_none should have an upper camel case name
--> src/prog/parameter.rs:14:5
|
14 | ct_none,
| ^^^^^^^ help: convert the identifier to upper camel case: CtNone
|
= note: #[warn(non_camel_case_types)] on by default

warning: variant ct_percent should have an upper camel case name
--> src/prog/parameter.rs:15:5
|
15 | ct_percent,
| ^^^^^^^^^^ help: convert the identifier to upper camel case: CtPercent

warning: variant ct_percent_bidi should have an upper camel case name
--> src/prog/parameter.rs:16:5
|
16 | ct_percent_bidi,
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to upper camel case: CtPercentBidi

...

warning: union is never used: PData
--> src/prog/parameter.rs:2:7
|
2 | union PData {
| ^^^^^
|
= note: #[warn(dead_code)] on by default

warning: enum is never used: ValTypes
--> src/prog/parameter.rs:8:6
|
8 | enum ValTypes {
| ^^^^^^^^

warning: enum is never used: CtrlTypes
--> src/prog/parameter.rs:13:6
|
13 | enum CtrlTypes {
| ^^^^^^^^^

warning: enum is never used: ControlGroup
--> src/prog/parameter.rs:99:6
|
99 | enum ControlGroup
| ^^^^^^^^^^^^

warning: struct is never constructed: XIDPromise
--> src/prog/parameter.rs:125:8
|
125 | struct XIDPromise {
| ^^^^^^^^^^^^^^^^^^

warning: struct is never constructed: XIDCounter
--> src/prog/parameter.rs:130:8
|
130 | struct XIDCounter {
| ^^^^^^^^^^^^^^^^^^

warning: 94 warnings emitted

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

$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)

nothing to commit, working tree clean

^^here, I expected some sort of lint fixing to be done automatically

Steps

run "cargo fix"in a project with some non camel case values within an enum.

I was expecting this command to automatically fix the suggested lints. Instead, git status indicates no change to the project directory.
Perhaps I have the command wrong. I read the manpage for cargo fix and it seemed to indicate I had the right command.

Notes

Output of cargo version:

$ cargo version
cargo 1.48.0-nightly (126907a 2020-08-31)

$ rustc --version
rustc 1.48.0-nightly (5099914a1 2020-09-08)

OS Platform : OSX 10.15.6

Additionally, I tried cargo clippy. This command gave me the expected behavior, but not on the camelcase lints I wanted it to fix! It found a set of hygiene issues I did not previously know about! How can I get this behavior for the camelcase lints! I grepped rustc-clippy and didn't find anything geared towards these particular camelcase lints. The enums in question are ported from C and sometimes have hundreds of non camelcase elements. It would be super useful to me if there was a command which could apply the suggested lints automatically!

Any help is much appreciated! thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.Command-fixS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions