Skip to content

Commit c8fad5b

Browse files
committed
Auto merge of #7157 - ehuss:force-clippy, r=alexcrichton
Force clippy to run. This causes `cargo clippy-preview` to always run, instead of possibly emitting no output if it is run a second time. This is just a personal preference of mine, but I think would be better behavior which we have talked about before. I don't think the arguments that it should be "fast" like `cargo check` apply here. Once [cache-messages](#6986) is stabilized, this can be removed.
2 parents 2b9b7e9 + 1c6d8bb commit c8fad5b

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/bin/cargo/commands/clippy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
7171

7272
let wrapper = util::process(util::config::clippy_driver());
7373
compile_opts.build_config.primary_unit_rustc = Some(wrapper);
74+
compile_opts.build_config.force_rebuild = true;
7475

7576
ops::compile(&ws, &compile_opts)?;
7677
Ok(())

tests/testsuite/clippy.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use crate::support::{clippy_is_available, project, registry::Package};
2+
3+
#[cargo_test]
4+
// Clippy should never be considered fresh.
5+
fn clippy_force_rebuild() {
6+
if !clippy_is_available() {
7+
return;
8+
}
9+
10+
Package::new("dep1", "0.1.0").publish();
11+
12+
// This is just a random clippy lint (assertions_on_constants) that
13+
// hopefully won't change much in the future.
14+
let p = project()
15+
.file(
16+
"Cargo.toml",
17+
r#"
18+
[package]
19+
name = "foo"
20+
version = "0.1.0"
21+
22+
[dependencies]
23+
dep1 = "0.1"
24+
"#,
25+
)
26+
.file("src/lib.rs", "pub fn f() { assert!(true); }")
27+
.build();
28+
29+
p.cargo("clippy-preview -Zunstable-options -v")
30+
.masquerade_as_nightly_cargo()
31+
.with_stderr_contains("[..]assert!(true)[..]")
32+
.run();
33+
34+
// Make sure it runs again.
35+
p.cargo("clippy-preview -Zunstable-options -v")
36+
.masquerade_as_nightly_cargo()
37+
.with_stderr_contains("[FRESH] dep1 v0.1.0")
38+
.with_stderr_contains("[..]assert!(true)[..]")
39+
.run();
40+
}

tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mod cargo_features;
2929
mod cfg;
3030
mod check;
3131
mod clean;
32+
mod clippy;
3233
mod collisions;
3334
mod concurrent;
3435
mod config;

0 commit comments

Comments
 (0)