Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/cargo/ops/cargo_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{Config, Progress, ProgressStyle};

use anyhow::Context as _;
use anyhow::{bail, Context as _};
use cargo_util::paths;
use std::fs;
use std::path::Path;
Expand All @@ -33,6 +33,15 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> {

// If the doc option is set, we just want to delete the doc directory.
if opts.doc {
if !opts.spec.is_empty() {
// FIXME: https://github.com/rust-lang/cargo/issues/8790
Comment on lines +36 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This culd be done with clap but sicne this is just a fixme, it likely doesn't matter

// This should support the ability to clean specific packages
// within the doc directory. It's a little tricky since it
// needs to find all documentable targets, but also consider
// the fact that target names might overlap with dependency
// names and such.
bail!("--doc cannot be used with -p");
}
target_dir = target_dir.join("doc");
return clean_entire_folder(&target_dir.into_path_unlocked(), config);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testsuite/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,13 @@ fn clean_spec_reserved() {
)
.run();
}

#[cargo_test]
fn doc_with_package_selection() {
// --doc with -p
let p = project().file("src/lib.rs", "").build();
p.cargo("clean --doc -p foo")
.with_status(101)
.with_stderr("error: --doc cannot be used with -p")
.run();
}