Skip to content

Commit f4dcb2b

Browse files
committed
remove clippy_hackery
1 parent 2c0a4df commit f4dcb2b

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

src/bin/cargo/commands/clippy.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
7272

7373
let mut wrapper = util::process(util::config::clippy_driver());
7474

75-
if let Some(old_args) = args.values_of("args") {
76-
let clippy_args: String = old_args
77-
.map(|arg| format!("{}__CLIPPY_HACKERY__", arg))
78-
.collect();
79-
wrapper.env("CLIPPY_ARGS", clippy_args);
75+
if let Some(clippy_args) = args.values_of("args") {
76+
wrapper.args(&clippy_args.collect::<Vec<_>>());
8077
}
8178

8279
compile_opts.build_config.primary_unit_rustc = Some(wrapper);

src/cargo/core/compiler/build_config.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,21 @@ pub struct BuildConfig {
2525
/// Output a build plan to stdout instead of actually compiling.
2626
pub build_plan: bool,
2727
/// An optional override of the rustc path for primary units only
28-
pub primary_unit_rustc: Option<ProcessBuilder>,
28+
pub primary_unit_rustc: Option<PrimaryUnitRustc>,
2929
pub rustfix_diagnostic_server: RefCell<Option<RustfixDiagnosticServer>>,
3030
/// Whether or not Cargo should cache compiler output on disk.
3131
cache_messages: bool,
3232
}
3333

34+
/// Configuration for subcommand specific rustc override
35+
#[derive(Debug, Clone)]
36+
pub struct PrimaryUnitRustc {
37+
/// ProcessBuilder to use instead of the default provided by `Rustc`
38+
pub proc: ProcessBuilder,
39+
/// Configure whether or not to use this as a wrapper around the original rustc process
40+
pub is_wrapper: bool,
41+
}
42+
3443
impl BuildConfig {
3544
/// Parses all config files to learn about build configuration. Currently
3645
/// configured options are:

src/cargo/core/compiler/compilation.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ impl<'cfg> Compilation<'cfg> {
8080

8181
let mut primary_unit_rustc_process =
8282
bcx.build_config.primary_unit_rustc.clone().map(|mut r| {
83-
r.arg(&bcx.rustc.path);
84-
r
83+
if r.is_wrapper {
84+
r.proc.arg(&bcx.rustc.path);
85+
}
86+
r.proc
8587
});
8688

8789
if bcx.config.extra_verbose() {

src/cargo/core/compiler/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use log::debug;
2424
use same_file::is_same_file;
2525
use serde::Serialize;
2626

27-
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat};
27+
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, PrimaryUnitRustc};
2828
pub use self::build_context::{BuildContext, FileFlavor, TargetConfig, TargetInfo};
2929
use self::build_plan::BuildPlan;
3030
pub use self::compilation::{Compilation, Doctest};

src/cargo/ops/fix.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use log::{debug, trace, warn};
5151
use rustfix::diagnostics::Diagnostic;
5252
use rustfix::{self, CodeFix};
5353

54+
use crate::core::compiler::PrimaryUnitRustc;
5455
use crate::core::Workspace;
5556
use crate::ops::{self, CompileOptions};
5657
use crate::util::diagnostic_server::{Message, RustfixDiagnosticServer};
@@ -132,7 +133,10 @@ pub fn fix(ws: &Workspace<'_>, opts: &mut FixOptions<'_>) -> CargoResult<()> {
132133

133134
// primary crates are compiled using a cargo subprocess to do extra work of applying fixes and
134135
// repeating build until there are no more changes to be applied
135-
opts.compile_opts.build_config.primary_unit_rustc = Some(wrapper);
136+
opts.compile_opts.build_config.primary_unit_rustc = Some(PrimaryUnitRustc {
137+
proc: wrapper,
138+
is_wrapper: true,
139+
});
136140

137141
ops::compile(ws, &opts.compile_opts)?;
138142
Ok(())

0 commit comments

Comments
 (0)