rustdoc: Allow linking from private items to private types
Fixes #74134 After PR #72771 this would trigger an intra_doc_link_resolution_failure warning when rustdoc is invoked without --document-private-items. Links from private items to private types are however never actually generated in that case and thus shouldn't produce a warning. These links are in fact a very useful tool to document crate internals. Tests are added for all 4 combinations of public/private items and link targets. Test 1 is the case mentioned above and fails without this commit. Tests 2 - 4 passed before already but are added nonetheless to prevent regressions.
This commit is contained in:
parent
8ac1525e09
commit
c8b16cdbd0
5 changed files with 44 additions and 0 deletions
10
src/test/rustdoc/issue-74134-1.rs
Normal file
10
src/test/rustdoc/issue-74134-1.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#![deny(intra_doc_link_resolution_failure)]
|
||||
|
||||
// Linking from a private item to a private type is fine without --document-private-items.
|
||||
|
||||
struct Private;
|
||||
|
||||
pub struct Public {
|
||||
/// [`Private`]
|
||||
private: Private,
|
||||
}
|
||||
11
src/test/rustdoc/issue-74134-2.rs
Normal file
11
src/test/rustdoc/issue-74134-2.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// compile-flags: --document-private-items
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
|
||||
// Linking from a private item to a private type is fine with --document-private-items.
|
||||
|
||||
struct Private;
|
||||
|
||||
pub struct Public {
|
||||
/// [`Private`]
|
||||
private: Private,
|
||||
}
|
||||
11
src/test/rustdoc/issue-74134-3.rs
Normal file
11
src/test/rustdoc/issue-74134-3.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// should-fail
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
|
||||
// Linking from a public item to a private type fails without --document-private-items.
|
||||
|
||||
struct Private;
|
||||
|
||||
pub struct Public {
|
||||
/// [`Private`]
|
||||
pub public: u32,
|
||||
}
|
||||
11
src/test/rustdoc/issue-74134-4.rs
Normal file
11
src/test/rustdoc/issue-74134-4.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// compile-flags: --document-private-items
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
|
||||
// Linking from a public item to a private type is fine with --document-private-items.
|
||||
|
||||
struct Private;
|
||||
|
||||
pub struct Public {
|
||||
/// [`Private`]
|
||||
pub public: u32,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue