This is tracked on the Clippy side with https://github.com/rust-lang/rust-clippy/issues/2604. For your point #1, you can use touch src/lib.rs
or whatever your root source file is to force a recompile.
Recently there was support added to Cargo to force a rebuild for cargo fix
, but it is not exposed externally. I’m not sure if this is the approach we ultimately want to go for clippy.
Eventually we want to cache diagnostic output. This is tracked in https://github.com/rust-lang/cargo/issues/3624. It is a relatively tricky problem to handle cross-platform. Recently, the fwdansi
crate was created and added to Cargo which is one of the steps to move this along. Cargo also now streams all rustc output, which was another step on this journey. I think at this point, the final bits need to be designed. Cargo needs to save off the diagnostics, and then replay them if the target is fresh. There are some tricky issues, like invalidating the cache if flags like --color
or --message-format
are changed. There was some discussion of always using JSON with rustc, and having Cargo responsible for re-rendering for text output, but that has additional complications (but some benefits).
I can try to take a look at moving this along sometime soonish.