forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustdoc: Allow linking from private items to private types
Fixes rust-lang#74134 After PR rust-lang#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.
- Loading branch information
1 parent
8ac1525
commit c8b16cd
Showing
5 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} |