-
Notifications
You must be signed in to change notification settings - Fork 1.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
BREAKING CHANGE fix running path/to/cargo-clippy --fix #9461
base: master
Are you sure you want to change the base?
Conversation
r? @giraffate (rust-highfive has picked a reviewer for you, use r? to override) |
src/main.rs
Outdated
// if we run "cargo clippy" (as cargo subcommand), we have to strip "cargo clippy" (first 2 args) | ||
// but if we are run via "..../target/debug/cargo-clippy", only ommit the first arg, the second one | ||
// might be a normal cmdline arg already (which we don't want to ommit) | ||
let args = if let Some(first_arg) = env::args().next() && (first_arg.ends_with("cargo-clippy") || first_arg.ends_with("cargo-clippy.exe")) { |
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.
We can avoid a breaking change by checking if the 2nd arg is clippy
, rather than the first being an invocation of cargo-clippy[.exe]
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.
ah so that cargo clippy
but also cargo-clippy clippy
still works? clever! :D
I'll revisit this tomorrow after a good portion of sleep :)
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.
That doesn't avoid the breaking change. Anything that uses cargo-clippy --
would break. Or anything else for that matter.
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.
That is what is happening for lintcheck
for example
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.
Ah right since any arg can currently be used as the separator
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.
cargo clippy
does execute with the first arg as .../cargo-clippy
though, so we'd still need a different approach
execve("/home/alex/.cargo/bin/cargo", ["cargo", "clippy"], 0xffffd242db68 /* 49 vars */) = 0
execve("/home/alex/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/bin/cargo", ["/home/alex/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/bin/cargo", "clippy"], 0xaaaae39b8940 /* 54 vars */) = 0
execve("/home/alex/.cargo/bin/cargo-clippy", ["/home/alex/.cargo/bin/cargo-clippy", "clippy"], 0xaaab0d612f40 /* 57 vars */) = 0
execve("/home/alex/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/bin/cargo-clippy", ["/home/alex/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/bin/cargo-clippy", "clippy"], 0xaaaafea6a490 /* 57 vars */) = 0```
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.
I just checked clippy 1.50
which was the lastest version when I wrote lintcheck 2 years ago and it looks like
RUSTC_BOOTSTRAP=1 ~/.rustup/toolchains/1.50-x86_64-unknown-linux-gnu/bin/cargo-clippy --fix -Zunstable-options
actually never worked as intended 😶 😅 😅
so to recap, on current master: |
I think the least breaking change we could do here is to check if the first argument is one of clippy's argument (currently Alternatively, we could just treat anything with a leading dash as an argument. This will break some scripts, but it will make any direct use of |
Doing a GitHub search I mostly find We also see |
Clippy meeting result:
|
Oh, and we should probably add a big disclaimer to the changelog :) |
There were several issues: - `--fix` was ignored as part of rust-lang#9461 - `--filter` in conjunction to `--fix` was broken due to rust-lang#9703 After `lintcheck --fix` is used, crates will be re-extracted since their content has been modified
There were several issues: - `--fix` was ignored as part of rust-lang#9461 - `--filter` in conjunction to `--fix` was broken due to rust-lang#9703 After `lintcheck --fix` is used, crates will be re-extracted since their content has been modified
There were several issues: - `--fix` was ignored as part of rust-lang#9461 - `--filter` in conjunction to `--fix` was broken due to rust-lang#9703 After `lintcheck --fix` is used, crates will be re-extracted since their content has been modified
There were several issues: - `--fix` was ignored as part of rust-lang#9461 - `--filter` in conjunction to `--fix` was broken due to rust-lang#9703 After `lintcheck --fix` is used, crates will be re-extracted since their content has been modified
I've now updated the changelog entry according to the meeting results listed above :) |
I'm marking this as waiting on author, until the discussed changes have been implemented. (Correct me, if I'm wrong with my assessment) @rustbot author |
Hey @matthiaskrgr, I'd like to announce this change one or two changelogs, before the version that puts this into effect. Can you address the comments and make this PR ready to be merged? Then I could include it in the |
This is not correct. I was unclear / ambiguous in my summary. The warning we want to emit for We want to keep supporting |
That makes a lot of sense, I had the feeling my understanding was not quite correct. Could you take a second look at the suggested changelog entry? |
Updated the changelog. |
I'll mark this as @rustbot label +I-blocked -S-waiting-on-author +beta-accepted |
Hey @matthiaskrgr, I'll mention this change in the next changelog, which unblocks this PR from being merged. Can you get this up to speed, with a rebase? |
Uuh i may need a bit to wrap my head around this again after 1.5 years I fear 😅 |
Very understandable ^^ (Sorry for the delay). The changelog doesn't mention a specific date or release, so there is no pressure from that side. |
In the last meeting we decided to not emit a warning, but rather break the behavior on a edition boundary. |
Is there already a date for the edition? And what is the best way to find out when it's scheduled to be released? |
I don't think there's a date for the edition. Not sure who's the edition manager though. |
Previously, we would assume clippy is called as "cargo clippy --arg1 --arg2" so we stripped the first two items and parsed "--arg1" and "--arg2" as cmdline args. The problem is when we run cargo-clippy binary directly as "target/debug/cargo-clippy --arg1 --arg2", we would still remove the first two args which would be "..cargo-clippy" and "--arg1" in this case which is wrong. Fix this by checking if we run clippy via "cargo clippy" or "../path/to/cargo-clippy" and for the latter, only skip the first arg instead of two. Spotted by Kraktus because lintcheck --fix was no longer working This is potentially a breaking change because the "target/debug/cargo-clippy clippy --fix" will no longer work! Use "target/debug/cargo-clippy --fix" directly instead. changelog: fix "cargo-clippy --foo" omitting the first flag, break "../cargo-clippy clippy --foo" which will now complain about the "clippy" arg.
…after edition 2024
if let Err(code) = process(env::args().skip(2)) { | ||
// if we run "cargo clippy" (as cargo subcommand), we have to strip "cargo clippy" (first 2 args) | ||
// but if we are run via "..../target/debug/cargo-clippy", only ommit the first arg, the second one | ||
// might be a normal cmdline arg already (which we don't want to ommit) | ||
let args = if let Some(first_arg) = env::args().next() | ||
&& (first_arg.ends_with("cargo-clippy") || first_arg.ends_with("cargo-clippy.exe")) | ||
{ | ||
// turn this of during the migration | ||
// env::args().skip(1) | ||
eprintln!( | ||
"WARNING: potentially breaking change: 'cargo-clippy arg1 arg2...' will no longer ignore 'arg1' after edition=2024" | ||
); | ||
env::args().skip(2) | ||
} else { | ||
env::args().skip(2) | ||
}; | ||
|
||
if let Err(code) = process(args) { |
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.
🤔
☔ The latest upstream changes (presumably #13225) made this pull request unmergeable. Please resolve the merge conflicts. |
Previously, we would assume clippy is called as "cargo clippy --arg1 --arg2" so we stripped the first two items and parsed "--arg1" and "--arg2" as cmdline args.
The problem is when we run cargo-clippy binary directly as "target/debug/cargo-clippy --arg1 --arg2", we would still remove the first two args which would be "..cargo-clippy" and "--arg1" in this case which is wrong.
Fix this by checking if we run clippy via "cargo clippy" or "../path/to/cargo-clippy" and for the latter, only skip the first arg instead of two.
Spotted by Kraktus because lintcheck --fix was no longer working
This is potentially a breaking change because the "target/debug/cargo-clippy clippy --fix" will no longer work!
Use "target/debug/cargo-clippy --fix" directly instead.
changelog: Important change:
cargo-clippy
will now no longer ignore the first argument.cargo-clippy clippy
will still work as documented (the secondclippy
is ignored). However, arguments like--fix
will issue a warning for now and will no longer be ignored in a few releases.cargo clippy
(without-
!) is unaffected by this change.#9461