-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add --fix support to cargo-clippy
#5363
Conversation
I'm worried about the Also I don't think we ever need to check for |
Assuming that we will only ever invoke the nightly version of |
About the nightly check: We could ship it without this check, since it will land on stable together with the current cargo. That means, that rustup users shouldn't trip over this change. If Clippy was compiled and installed from source, this might be a problem depending on the cargo version, that is used. |
I think if we merged it without the nightly check it would break clippy on stable if cargo doesn't stabilize |
Ah |
I don't know, if or how we can check if nightly cargo is used, so I guess we'll have to wait, until |
I'll ping @ehuss to see if he has any ideas. |
Perhaps the rustc_version crate could be helpful here? |
The intent was to have this as an unstable feature in clippy for a short while, and then stabilize it on both sides at some point. So you would specify I was initially thinking there might be some way for How does that sound? |
Sounds like a perfect solution |
Okay so this works now, wondering how much we care about getting the tests / help text change finished before merging this, given that its behind unstable options I'm thinking I should try to add one test to ensure that when we enable unstable options we call cargo with |
I agree. A test for this would be good. The help can be adapted later. |
I merged this branch with master and figured out how to compile my own Clippy, all because this type of thing is really valuable for revitalizing old projects (some of mine were started before Rust 1.0!). Looking forward to this being generally available. |
We could merge this and revisit testing this later. I'll take a final look at this later and then add it to the |
Also I know that the formatting is wrong but nightly rustfmt isnt available on the current nightly which is the only one that builds clippy soooooooooooooo /shrug |
@phansch can you re-review this please, I still have 5 PRs in my review queue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus the formatting I just have a small nit. Apart from that everything looks good to me =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dogfood:
Co-Authored-By: Philipp Krones <[email protected]>
@bors r=phansch,flip1995 Thanks! |
📌 Commit 5cfb9ec has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This has been unstable since it was first introduced in rust-lang#5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized.
This has been unstable since it was first introduced in rust-lang#5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized.
This has been unstable since it was first introduced in rust-lang#5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized.
This has been unstable since it was first introduced in rust-lang#5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized.
This has been unstable since it was first introduced in rust-lang#5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized.
Stabilize `cargo clippy --fix` This has been unstable since it was first introduced in #5363. In that time, I have been using it successfully in nightly without issues. I don't think there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is stabilized, so this can be stabilized. changelog: Stabilize `cargo clippy --fix`
Prior to this we had started work on integrating clippy as a subcommand directly into cargo in the form of
cargo clippy-preview
andcargo fix --clippy
. In the course of that work it was decided that the best approach would be to strictly add the features clippy needed to cargo in order to insertclippy-driver
only for workspace crates. This was accomplished by adding aRUSTC_WORKSPACE_WRAPPER
env variable to cargo that will override the normalRUSTC_WRAPPER
when both are present and the current crate is a workspace crate.This change adds support to clippy to use this by setting the
RUSTC_WORKSPACE_WRAPPER
env variable insteadRUSTC_WRAPPER
and by detecting--fix
as an arg and swapping out thecheck
cargo command forfix
when it is present.WIP, here are the current issues that I still need to resolve
RUSTC_WORKSPACE_WRAPPER
on nightly, andRUSTC_WRAPPER
on stable--fix
is specified, because stable currently hasn't landed the PR forRUSTC_WORKSPACE_WRAPPER
so if we set this it just runs check and silently failscargo check --help
and then postprocess the output to mention clippy instead of check where appropriate and to add the extra info about--fix
and the-- -A lint
options.changelog: add
--fix
arg tocargo-clippy