mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
When documenting private items in a binary, ignore warnings about links to private items
Previously, rustdoc would warn about linking to items in a binary, even though cargo unconditionally documents private items in a binary. This changes cargo to silence the warning, since it's only relevant in cases where the private items might not be documented.
This commit is contained in:
parent
01c06b0360
commit
727baf0db1
@ -646,6 +646,12 @@ pub fn create_bcx<'a, 'cfg>(
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -2767,3 +2767,24 @@ fn doc_check_cfg_features() {
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn link_to_private_item() {
|
||||
let main = r#"
|
||||
//! [bar]
|
||||
#[allow(dead_code)]
|
||||
fn bar() {}
|
||||
"#;
|
||||
let p = project().file("src/lib.rs", main).build();
|
||||
p.cargo("doc")
|
||||
.with_stderr_contains("[..] documentation for `foo` links to private item `bar`")
|
||||
.run();
|
||||
// Check that binaries don't emit a private_intra_doc_links warning.
|
||||
fs::rename(p.root().join("src/lib.rs"), p.root().join("src/main.rs")).unwrap();
|
||||
p.cargo("doc")
|
||||
.with_stderr(
|
||||
"[DOCUMENTING] foo [..]\n\
|
||||
[FINISHED] [..]",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user