Skip to content

Commit c5161ac

Browse files
committed
refactor(clean): Pull out the layout conditional
1 parent 151d3b7 commit c5161ac

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/cargo/ops/cargo_clean.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,8 @@ fn clean_specs(
192192

193193
clean_ctx.progress = Box::new(CleaningPackagesBar::new(clean_ctx.gctx, packages.len()));
194194

195-
{
196-
// Try to reduce the amount of times we iterate over the same target directory by storing away
197-
// the directories we've iterated over (and cleaned for a given package).
198-
let mut cleaned_packages: HashMap<_, HashSet<_>> = HashMap::default();
195+
if clean_ctx.gctx.cli_unstable().build_dir_new_layout {
199196
for pkg in packages {
200-
let pkg_dir = format!("{}-*", pkg.name());
201197
clean_ctx.progress.on_cleaning_package(&pkg.name())?;
202198

203199
if clean_ctx.gctx.cli_unstable().build_dir_new_layout {
@@ -247,6 +243,14 @@ fn clean_specs(
247243
}
248244
continue;
249245
}
246+
}
247+
} else {
248+
// Try to reduce the amount of times we iterate over the same target directory by storing away
249+
// the directories we've iterated over (and cleaned for a given package).
250+
let mut cleaned_packages: HashMap<_, HashSet<_>> = HashMap::default();
251+
for pkg in packages {
252+
let pkg_dir = format!("{}-*", pkg.name());
253+
clean_ctx.progress.on_cleaning_package(&pkg.name())?;
250254

251255
// Clean fingerprints.
252256
for (_, layout) in &layouts_with_host {

0 commit comments

Comments
 (0)