Skip to content

Commit

Permalink
Remove unused CompileOptions.local_rustdoc_args
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Oct 16, 2022
1 parent 3fd7580 commit 0195423
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
47 changes: 18 additions & 29 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ pub struct CompileOptions {
pub target_rustc_args: Option<Vec<String>>,
/// Crate types to be passed to rustc (single target only)
pub target_rustc_crate_types: Option<Vec<String>>,
/// Extra arguments passed to all selected targets for rustdoc.
pub local_rustdoc_args: Option<Vec<String>>,
/// Whether the `--document-private-items` flags was specified and should
/// be forwarded to `rustdoc`.
pub rustdoc_document_private_items: bool,
Expand All @@ -110,7 +108,6 @@ impl CompileOptions {
target_rustdoc_args: None,
target_rustc_args: None,
target_rustc_crate_types: None,
local_rustdoc_args: None,
rustdoc_document_private_items: false,
honor_rust_version: true,
})
Expand Down Expand Up @@ -206,7 +203,6 @@ pub fn create_bcx<'a, 'cfg>(
ref target_rustdoc_args,
ref target_rustc_args,
ref target_rustc_crate_types,
ref local_rustdoc_args,
rustdoc_document_private_items,
honor_rust_version,
} = *options;
Expand Down Expand Up @@ -481,32 +477,25 @@ pub fn create_bcx<'a, 'cfg>(
extra_compiler_args.insert(units[0].clone(), args);
}

for unit in &units {
if unit.mode.is_doc() || unit.mode.is_doc_test() {
let mut extra_args = local_rustdoc_args.clone();

// 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_default();
args.push("--document-private-items".into());
if unit.target.is_bin() {
// This warning only makes sense if it's possible to document private items
// sometimes and ignore them at other times. But cargo consistently passes
// `--document-private-items`, so the warning isn't useful.
args.push("-Arustdoc::private-intra-doc-links".into());
}
extra_args = Some(args);
}

if let Some(args) = extra_args {
extra_compiler_args
.entry(unit.clone())
.or_default()
.extend(args);
}
for unit in units
.iter()
.filter(|unit| unit.mode.is_doc() || unit.mode.is_doc_test())
.filter(|unit| rustdoc_document_private_items || unit.target.is_bin())
{
// Add `--document-private-items` rustdoc flag if requested or if
// the target is a binary. Binary crates get their private items
// documented by default.
let mut args = vec!["--document-private-items".into()];
if unit.target.is_bin() {
// This warning only makes sense if it's possible to document private items
// sometimes and ignore them at other times. But cargo consistently passes
// `--document-private-items`, so the warning isn't useful.
args.push("-Arustdoc::private-intra-doc-links".into());
}
extra_compiler_args
.entry(unit.clone())
.or_default()
.extend(args);
}

if honor_rust_version {
Expand Down
1 change: 0 additions & 1 deletion src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,6 @@ fn run_verify(
target_rustdoc_args: None,
target_rustc_args: rustc_args,
target_rustc_crate_types: None,
local_rustdoc_args: None,
rustdoc_document_private_items: false,
honor_rust_version: true,
},
Expand Down
1 change: 0 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ pub trait ArgMatchesExt {
target_rustdoc_args: None,
target_rustc_args: None,
target_rustc_crate_types: None,
local_rustdoc_args: None,
rustdoc_document_private_items: false,
honor_rust_version: !self.flag("ignore-rust-version"),
};
Expand Down

0 comments on commit 0195423

Please sign in to comment.