Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop adding the --document-private-items flag if it's already being set #8422

Closed
Closed
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
16 changes: 12 additions & 4 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,18 @@ pub fn create_bcx<'a, 'cfg>(
// Add `--document-private-items` rustdoc flag if requested or if
// the target is a binary. Binary crates get their private items
// documented by default.
if rustdoc_document_private_items || unit.target.is_bin() {
let mut args = extra_args.take().unwrap_or_else(|| vec![]);
args.push("--document-private-items".into());
extra_args = Some(args);
// Don't add the flag if it's already there, because that's an error.
let document_private_items_flag = "--document-private-items".to_string();
if !target_data
.info(unit.kind)
.rustdocflags
.contains(&document_private_items_flag)
{
if rustdoc_document_private_items || unit.target.is_bin() {
let mut args = extra_args.take().unwrap_or_else(|| vec![]);
args.push(document_private_items_flag);
extra_args = Some(args);
}
}

if let Some(args) = extra_args {
Expand Down