-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 clippy and fix commands to x.py #56595
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #56258) made this pull request unmergeable. Please resolve the merge conflicts. |
bootstrap: fix edition A byproduct of work on rust-lang#56595; done with `cargo fix --edition`.
bootstrap: fix edition A byproduct of work on rust-lang#56595; done with `cargo fix --edition`.
bootstrap: fix edition A byproduct of work on rust-lang#56595; done with `cargo fix --edition`.
bootstrap: fix edition A byproduct of work on rust-lang#56595; done with `cargo fix --edition`.
Thanks for the PR! I'm somewhat hesitant to merge this in though because it seems like it's presumably duplicating a lot of code already there for other aspects of rustbuild. Rustbuild already suffers from a good deal of duplication, so I think I'd personally prefer if we could try to explore strategies of deduplication before merging these in |
I would kind of like to merge this actually. It would be a big step towards moving the compiler to edition 2018. |
@alexcrichton there is definitely room for improvement in terms of deduplication, that's one of the reasons for the WIP; I just wanted to make sure the general approach was fine before squeezing the code a bit more. I'll rebase and deduplicate the code shortly. |
9135b3e
to
0e43db1
Compare
@alexcrichton I updated the commit - the new commands are now integrated into |
bootstrap: fix edition A byproduct of work on #56595; done with `cargo fix --edition`.
☔ The latest upstream changes (presumably #56600) made this pull request unmergeable. Please resolve the merge conflicts. |
0e43db1
to
aee9a7a
Compare
Rebased. |
src/bootstrap/check.rs
Outdated
@@ -23,6 +23,22 @@ pub struct Std { | |||
pub target: Interned<String>, | |||
} | |||
|
|||
fn args(kind: Kind) -> Vec<String> { | |||
match kind { | |||
Kind::Clippy => vec!["--".to_owned(), "-W".to_owned(), "clippy::all".to_owned()], |
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.
-W clippy::all breaks on any error. Is there a way to produce errors but not have them break the progress?
--cap-lints warn
should work.
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 managed to pass it into clippy
arguments, but it doesn't seem to be enough 🤔.
You can make
This is also due to rustc shim. It removes |
Thanks for the suggestions @sinkuu! I'll apply them soon. Edit: I added |
5176bb1
to
0820b48
Compare
@ljedrz you can now have the colors in the |
Thanks! I'm currently traveling, but I'll get back to this shortly. |
With the addition of the new flag we now have available thanks to @oli-obk, I am now able to run e.g. This option doesn't seem to be available to |
It sounds like a nice addition, but perhaps in a followup PR? |
Done; at this point the |
The entirety of the repo (+ relevant submodules) has been moved to 2018 so this PR is no longer needed for that. (but it is still nice for other things...) |
r? @oli-obk |
☔ The latest upstream changes (presumably #60568) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -898,6 +902,11 @@ impl<'a> Builder<'a> { | |||
extra_args.push_str(&s); | |||
} | |||
|
|||
if cmd == "clippy" { | |||
extra_args.push_str("-Zforce-unstable-if-unmarked -Zunstable-options \ |
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.
have you tested that this prevents the rebuilds? I would have assumed this to still cause build thrashing. If this works, then I'm happy with it, if not, you should be able to add them in the args
function you created below by putting them after a --
argument
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 it - there are no rebuilds. The only thing is that after throwing its warnings (a lot of stuff found in libcore
) ./x.py clippy
is complaining that it can't find crate for std
and I no longer remember if this was an acceptable step forward or not ^^. I remember having trouble making it respect the build order.
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.
While not great, we can solve this in follow-ups. I think this may happen whenever one tries to run clippy on a target without libstd, so it's likely that it's a clippy issue.
@bors r+ |
📌 Commit 2f3533b has been approved by |
Add clippy and fix commands to x.py Since they are kind of similar in nature, I have used the same approach as for `cargo check`. At least some of the boilerplate could probably be shared, but I'd prefer to gather some feedback before I decide to merge them more aggressively. This works reasonably well for `clippy`; with `-A clippy::all` and some extra `#![feature(rustc_private)]`s almost the whole codebase can be processed. There are some concerns, though: - unlike `check`, in order to be able to traverse all the crates, some of them need to be marked with the `#![feature(rustc_private)]` attribute - `-W clippy::all` breaks on any error. Is there a way to produce errors but not have them break the progress? - I'm not sure how to redirect the errors in a way that would show colors; for now I was able to de-jsonize and print them (something not needed for `check`) `cargo fix` is much more stubborn; it refuses to acknowledge crates like `core` and `std`, so it doesn't progress much at all. Since this is a bit more tricky than I have envisioned, I need some guidance: - is this the right approach or am I doing something very wrong ^^? - why are the extra `rustc_private` features necessary? I was hoping for the same treatment as `check` - are changes in `clippy` and `cargo fix` needed e.g. in order to produce errors in the same manner as `check` or did I miss something? - do we need this level of file granularity (e.g. for futureproofing) or can `check`, `clippy` and `fix` files be condensed? Hopes-to-fix: #53896 Cc @alexcrichton, @zackmdavis
☀️ Test successful - checks-travis, status-appveyor |
Emit ansi color codes in the `rendered` field of json diagnostics cc @ljedrz Implemented for rust-lang/rust#56595 (comment) (x.py clippy)
Since they are kind of similar in nature, I have used the same approach as for
cargo check
. At least some of the boilerplate could probably be shared, but I'd prefer to gather some feedback before I decide to merge them more aggressively.This works reasonably well for
clippy
; with-A clippy::all
and some extra#![feature(rustc_private)]
s almost the whole codebase can be processed. There are some concerns, though:check
, in order to be able to traverse all the crates, some of them need to be marked with the#![feature(rustc_private)]
attribute-W clippy::all
breaks on any error. Is there a way to produce errors but not have them break the progress?check
)cargo fix
is much more stubborn; it refuses to acknowledge crates likecore
andstd
, so it doesn't progress much at all.Since this is a bit more tricky than I have envisioned, I need some guidance:
rustc_private
features necessary? I was hoping for the same treatment ascheck
clippy
andcargo fix
needed e.g. in order to produce errors in the same manner ascheck
or did I miss something?check
,clippy
andfix
files be condensed?Hopes-to-fix: #53896
Cc @alexcrichton, @zackmdavis