-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cargo fix: tell user why some fixes aren't applied (such as maybe-incorrect) #8806
Comments
Thanks for the report! In this particular case, the lint is marked as There is an issue for forcing Perhaps |
@ehuss part of the solution here would be to make |
I'm a little confused, as there are multiple things being discussed here, and I don't understand the For this issue, Cargo could write a note at the end that some suggestions weren't applied. It'll be a little tricky. The final messages are displayed here by running rustc. However, this "inner" cargo wrapper doesn't capture the output during this final run, so it doesn't know which suggestions were remaining. There are a few different approaches to that. One is to intercept all the output, reparse it, and catch all the suggestions, and if there are any, displaying a note that it wasn't applied. Another option is to send some signal to the "outer" cargo to do that same work. Either way probably won't be pretty. If you are talking about adding some kind of flag to do the equivalent of Or maybe you are talking about #13023 where Or maybe you are talking about having an interactive UI to choose applying lints? Rustfix used to have that, but it was removed. We could consider that, too, but I'm wondering why someone would prefer to use that over an IDE? I would presume the majority of users are using some kind of smart editor where they can just make that choice there. I'm not saying the command-line It would be helpful to better understand the use cases you want to address, and how common or useful we would expect those to be. |
@ehuss I think the solution proposed in #13028 is quite doable:
The |
I was bringing it up in the context of
to make the suggestion |
rustfix-the-library doesn't (and can't) print anything. It would need to be done in |
Ah, I see. Would be nice to have that, we could potentially signal this state through the return code idk |
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 defaultwarning: 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 defaultwarning: 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
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
: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!
The text was updated successfully, but these errors were encountered: