Skip to content

Commit c204734

Browse files
committed
Don't display paths with cargo clean --dry-run without --verbose
The paths themselves aren't particularly interesting.
1 parent f61d42d commit c204734

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/cargo/ops/cargo_clean.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,8 @@ impl<'cfg> CleanContext<'cfg> {
334334
}
335335
};
336336

337-
if self.dry_run {
338-
// Concise because if in verbose mode, the path will be written in
339-
// the loop below.
340-
self.config
341-
.shell()
342-
.concise(|shell| Ok(writeln!(shell.out(), "{}", path.display())?))?;
343-
} else {
337+
// dry-run displays paths while walking, so don't print here.
338+
if !self.dry_run {
344339
self.config
345340
.shell()
346341
.verbose(|shell| shell.status("Removing", path.display()))?;
@@ -369,6 +364,10 @@ impl<'cfg> CleanContext<'cfg> {
369364
let entry = entry?;
370365
self.progress.on_clean()?;
371366
if self.dry_run {
367+
// This prints the path without the "Removing" status since I feel
368+
// like it can be surprising or even frightening if cargo says it
369+
// is removing something without actually removing it. And I can't
370+
// come up with a different verb to use as the status.
372371
self.config
373372
.shell()
374373
.verbose(|shell| Ok(writeln!(shell.out(), "{}", entry.path().display())?))?;

tests/testsuite/clean.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ fn clean_dry_run() {
825825
p.cargo("check").run();
826826
let before = ls_r();
827827
p.cargo("clean --dry-run")
828-
.with_stdout("[CWD]/target")
829828
.with_stderr(
830829
"[SUMMARY] [..] files, [..] total\n\
831830
[WARNING] no files deleted due to --dry-run",

0 commit comments

Comments
 (0)