Skip to content

Commit 40ee338

Browse files
committed
refactor: simplify logic of env var diplay with -vv
1 parent 2e7fc43 commit 40ee338

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/cargo/core/compiler/compilation.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,9 @@ pub struct Compilation<'gctx> {
129129

130130
impl<'gctx> Compilation<'gctx> {
131131
pub fn new<'a>(bcx: &BuildContext<'a, 'gctx>) -> CargoResult<Compilation<'gctx>> {
132-
let mut rustc = bcx.rustc().process();
133-
let mut primary_rustc_process = bcx.build_config.primary_unit_rustc.clone();
134-
let mut rustc_workspace_wrapper_process = bcx.rustc().workspace_process();
135-
136-
if bcx.gctx.extra_verbose() {
137-
rustc.display_env_vars();
138-
rustc_workspace_wrapper_process.display_env_vars();
139-
140-
if let Some(rustc) = primary_rustc_process.as_mut() {
141-
rustc.display_env_vars();
142-
}
143-
}
144-
132+
let rustc_process = bcx.rustc().process();
133+
let primary_rustc_process = bcx.build_config.primary_unit_rustc.clone();
134+
let rustc_workspace_wrapper_process = bcx.rustc().workspace_process();
145135
Ok(Compilation {
146136
native_dirs: BTreeSet::new(),
147137
root_output: HashMap::new(),
@@ -155,7 +145,7 @@ impl<'gctx> Compilation<'gctx> {
155145
to_doc_test: Vec::new(),
156146
gctx: bcx.gctx,
157147
host: bcx.host_triple().to_string(),
158-
rustc_process: rustc,
148+
rustc_process,
159149
rustc_workspace_wrapper_process,
160150
primary_rustc_process,
161151
target_runners: bcx
@@ -189,14 +179,16 @@ impl<'gctx> Compilation<'gctx> {
189179
is_primary: bool,
190180
is_workspace: bool,
191181
) -> CargoResult<ProcessBuilder> {
192-
let rustc = if is_primary && self.primary_rustc_process.is_some() {
182+
let mut rustc = if is_primary && self.primary_rustc_process.is_some() {
193183
self.primary_rustc_process.clone().unwrap()
194184
} else if is_workspace {
195185
self.rustc_workspace_wrapper_process.clone()
196186
} else {
197187
self.rustc_process.clone()
198188
};
199-
189+
if self.gctx.extra_verbose() {
190+
rustc.display_env_vars();
191+
}
200192
let cmd = fill_rustc_tool_env(rustc, unit);
201193
self.fill_env(cmd, &unit.pkg, None, unit.kind, ToolKind::Rustc)
202194
}

0 commit comments

Comments
 (0)