-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
call clippy-driver directly rather than as a rustc_wrapper #7006
Comments
Bumping this for the notification for alex |
Thanks for the ping @yaahallo! At this point I think the next steps are basically to just go ahead and implement this in Cargo under a new name, get some tests running, and go from there. (making sure it's all unstable so we can test it out before fully switching over) Do you need some help about doing this in Cargo? If so, we can always try to help out! |
@alexcrichton I think I can handle getting started and then rely on code review for course correction :) |
Oh, here's how we'd like it to work:
These don't have to be fixed here, but we should design it such that these can be made to work. @alexcrichton got any tips for how best to design this? I think an additional flag in the check compile mode that gets passed around everywhere would be nice, i.e. we should not make this an internal rustc wrapper. |
RE: bullet point 2 is there any reason not to support both |
I don't think I have a strong enough grasp on what needs to be done here to say how to design it best, but I'm more than happy to read over PRs and offer guidance! I suspect that something cargo-fix like is appropriate here, though. I'd probably start with |
rust-lang/rustfix#130 just gonna link this here since it seems related |
@killercup should I just dissect how all the json format stuff works and essentially bake the minimum necessary logic from https://github.com/rust-lang-nursery/rustfix/blob/2239a2386d72a6b2db6d904e0b1b5cc6e5525533/examples/fix-json.rs into cargo? My current plan is to start with |
I think going with There's also the question of the union of flags from
As for implementation, I think it should be a relatively simple thing. The |
I would rather move away from using a wrapper since it interacts badly with other wrappers (e.g. sccache). I feel like an internal flag that makes a check compilation mode clippylike is what we'll end up needing for that, so cargo clippy is internally "clippylike cargo check", and cargo fix --clippy is "clippylike cargo fix". To be clear, I don't think we should worry about UI just yet, the reason I suggest |
My point is that supporting clippy in What is the use case for clippy and sccache? Doesn't clippy inherently want to force a run, and sccache caching isn't desired? Here are some things I'd like to see addressed:
The only way I can think of for now to start on this is to have For forcing, I think clippy can just set For the third point, we'll need to add something to the fingerprint when clippy is running. I was originally considering adding rustc_wrapper to the fingerprint, but that might have some unexpected consequences. Clippy and sccache are some of the main users of RUSTC_WRAPPER that I know of. I think sccache will be ok, although it might cause recompiles if you enable/disable it, that might be a good thing? The old |
That's the issue though! You only want to run clippy-driver on the last crate (or, in the case of This is not something wrapper functionality exposes at the moment. What clippy currently does is basically guess if it needs to be run on a given crate, and shell out to rustc otherwise. This has bugs.
Again, dependencies. You want sccache for deps and clippy for the final check.
+1
Honestly I think it won't be productive to generalize this to a new kind of wrapper, we should just start with a flag that controls if it's a clippy run, and if so, inserts clippy-driver calls. But if you feel this is the better way, we can do it that way. |
If you mean for the
Ah, yea, if the "wrapper for primary only" is implemented, this should just work.
I think it will be fine to be general. (Note: I edited my comment above, I was mistaken on how |
SGTM, you know your own codebase better 😄 |
That is correct, I toyed with having clippy wrappers stored in a vec rather than just as a single item, but we didn't want to derail that PR with figuring out what that would entail so we decided to shelve the idea. |
Also, I'm going to outline what I plan on doing based on the conversation over the weekend, please correct anything that I get wrong.
I dont know what the rmeta cache is yet so I'll need some more info to understand this and what needs to be done here. As a bonus I might spend some time testing the interaction between sccache and all of the above changes to make sure they get along nicely. |
That's a lower priority right now, just something I'd like to see done to get message caching working better. We'll also need to determine if it is correct/safe to cache clippy output (in which case we can skip the whole "force" thing once message caching is stabilized). I'm not 100% this will all work, but I think it should. This may have subtle effects with other use cases, so it will need some testing. |
initial working version of cargo fix --clippy closes #7006
As part of our ongoing effort in rust-lang/rust-clippy#3837 to move clippy up into cargo so we can integrate it with fix and maybe other features that @Manishearth can add we're thinking the next step is to tweek clippy-preview so that it calls clippy-driver directly rather than treating it like a rustc wrapper.
When we looked into making it so that clippy-driver can be called as rustc instead of as a rustc wrapper, we realized it really doesn't do anything when its being a wrapper other than remove the rustc argument from the args list. So we should already be good to go on that front.
I'd like to implement this feature myself but manish and I don't know cargo well enough to know the proper way to go about it and manish recommended I ask @alexcrichton and @killercup for ideas on how to go about doing it.
Some additional questions from manish
fix
integration? if not, what would?rust-lang/rust-clippy#2087 is relevant to that last question
cc @ehuss
Edit: tracking the checklist in original post rather than below
cargo fix --clippy
overcargo clippy-preview --fix
(gonna gate the --clippy arg behind the unstable flag in the same wayclippy-preview
is gated)implement wrapper for primary crate only logicunnecessarysupport using the wrapper for all local workspace crates when using theunnecessary--all
flagcargo fix
have clippy override the fingerprint to force a run when using cargo fixunnecessary?The text was updated successfully, but these errors were encountered: