Skip to content

Commit f3d3318

Browse files
committed
minor fixes
1 parent c0c6729 commit f3d3318

File tree

5 files changed

+44
-49
lines changed

5 files changed

+44
-49
lines changed

src/bin/cargo/commands/fix.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
142142
.or_else(|| Some(vec![]))
143143
.filter(|_| use_clippy);
144144

145-
// dbg!(&clippy_args, use_clippy);
146-
147145
if use_clippy && !config.cli_unstable().unstable_options {
148146
return Err(failure::format_err!(
149147
"`cargo fix --clippy` is unstable, pass `-Z unstable-options` to enable it"

src/cargo/ops/fix.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const BROKEN_CODE_ENV: &str = "__CARGO_FIX_BROKEN_CODE";
6363
const PREPARE_FOR_ENV: &str = "__CARGO_FIX_PREPARE_FOR";
6464
const EDITION_ENV: &str = "__CARGO_FIX_EDITION";
6565
const IDIOMS_ENV: &str = "__CARGO_FIX_IDIOMS";
66-
const CLIPPY_FIX_ENV: &str = "__CARGO_FIX_CLIPPY_PLZ";
6766
const CLIPPY_FIX_ARGS: &str = "__CARGO_FIX_CLIPPY_ARGS";
6867

6968
pub struct FixOptions<'a> {
@@ -106,13 +105,13 @@ pub fn fix(ws: &Workspace<'_>, opts: &mut FixOptions<'_>) -> CargoResult<()> {
106105
if let Err(e) = util::process("clippy-driver").arg("-V").exec_with_output() {
107106
eprintln!("Warning: clippy-driver not found: {:?}", e);
108107
}
109-
wrapper.env(CLIPPY_FIX_ENV, "1");
108+
110109
opts.compile_opts.build_config.primary_unit_rustc = Some(util::config::clippy_driver());
111-
}
112110

113-
if let Some(clippy_args) = &opts.clippy_args {
114-
let clippy_args = serde_json::to_string(&clippy_args).unwrap();
115-
wrapper.env(CLIPPY_FIX_ARGS, clippy_args);
111+
if let Some(clippy_args) = &opts.clippy_args {
112+
let clippy_args = serde_json::to_string(&clippy_args).unwrap();
113+
wrapper.env(CLIPPY_FIX_ARGS, clippy_args);
114+
}
116115
}
117116

118117
*opts

tests/testsuite/cache_messages.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::support::{is_nightly, process, project, registry::Package};
1+
use crate::support::{clippy_is_available, is_nightly, process, project, registry::Package};
22
use std::path::Path;
33

44
fn as_str(bytes: &[u8]) -> &str {
@@ -255,6 +255,44 @@ fn fix() {
255255
assert_eq!(p.read_file("src/lib.rs"), "pub fn r#try() {}");
256256
}
257257

258+
#[cargo_test]
259+
fn clippy() {
260+
if !is_nightly() {
261+
// --json-rendered is unstable
262+
eprintln!("skipping test: requires nightly");
263+
return;
264+
}
265+
266+
if !clippy_is_available() {
267+
return;
268+
}
269+
270+
// Caching clippy output.
271+
// This is just a random clippy lint (assertions_on_constants) that
272+
// hopefully won't change much in the future.
273+
let p = project()
274+
.file("src/lib.rs", "pub fn f() { assert!(true); }")
275+
.build();
276+
277+
p.cargo("clippy-preview -Zunstable-options -Zcache-messages")
278+
.masquerade_as_nightly_cargo()
279+
.with_stderr_contains("[..]assert!(true)[..]")
280+
.run();
281+
282+
// Again, reading from the cache.
283+
p.cargo("clippy-preview -Zunstable-options -Zcache-messages")
284+
.masquerade_as_nightly_cargo()
285+
.with_stderr_contains("[..]assert!(true)[..]")
286+
.run();
287+
288+
// FIXME: Unfortunately clippy is sharing the same hash with check. This
289+
// causes the cache to be reused when it shouldn't.
290+
p.cargo("check -Zcache-messages")
291+
.masquerade_as_nightly_cargo()
292+
.with_stderr_contains("[..]assert!(true)[..]") // This should not be here.
293+
.run();
294+
}
295+
258296
#[cargo_test]
259297
fn very_verbose() {
260298
if !is_nightly() {

tests/testsuite/clippy.rs

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/testsuite/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod cargo_features;
2929
mod cfg;
3030
mod check;
3131
mod clean;
32-
mod clippy;
3332
mod collisions;
3433
mod concurrent;
3534
mod config;

0 commit comments

Comments
 (0)