Skip to content
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

x.py clippy argument passing broken, order no loger preserved #121481

Closed
matthiaskrgr opened this issue Feb 22, 2024 · 0 comments · Fixed by #121543
Closed

x.py clippy argument passing broken, order no loger preserved #121481

matthiaskrgr opened this issue Feb 22, 2024 · 0 comments · Fixed by #121543
Assignees
Labels
A-clippy Area: Clippy T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 22, 2024

https://github.com/rust-lang/rust/blob/master/src/bootstrap/src/core/build_steps/check.rs#L66

apparently we now group the args passed to x.py clippy by lint level (allow, deny, etc) and then send group by group to the clippy command.

This is bad because you can no longer turn on/off single lints, for example x.py clippy -Aclippy:all -Wclippy::style -Aclippy::foo1 -Aclippy::foo2 used to only turn on style lints with the exception of foo1 and foo2.

The order is no longer preserved

        args.extend(strings(&["--", "--cap-lints", "warn"]));
        args.extend(ignored_lints.iter().map(|lint| format!("-Aclippy::{}", lint)));
        let mut clippy_lint_levels: Vec<String> = Vec::new();
        allow.iter().for_each(|v| clippy_lint_levels.push(format!("-A{}", v)));
        deny.iter().for_each(|v| clippy_lint_levels.push(format!("-D{}", v)));
        warn.iter().for_each(|v| clippy_lint_levels.push(format!("-W{}", v)));
        forbid.iter().for_each(|v| clippy_lint_levels.push(format!("-F{}", v)));
        args.extend(clippy_lint_levels);
        args.extend(builder.config.free_args.clone());

which would now become -Aclippy::all -Aclippy::foo1 -Aclippy::foo2 -Wclippy::style which kind of defeats the purpose of being able to setting specific lints to allow/warn.

@matthiaskrgr matthiaskrgr added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@jieyouxu jieyouxu added A-clippy Area: Clippy and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 23, 2024
@onur-ozkan onur-ozkan self-assigned this Feb 24, 2024
@bors bors closed this as completed in 4f3050b Mar 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 20, 2024
Rollup merge of rust-lang#121543 - onur-ozkan:clippy-args, r=oli-obk

various clippy fixes

We need to keep the order of the given clippy lint rules before passing them.
Since clap doesn't offer any useful interface for this purpose out of the box,
we have to handle it manually.

Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well.

Fixes rust-lang#121481
cc `@matthiaskrgr`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants