File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
compiler/rustc_session/src/lint Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -1831,7 +1831,7 @@ declare_lint! {
18311831 /// a public item to a private one. This is a `rustdoc` only lint, see the
18321832 /// documentation in the [rustdoc book].
18331833 ///
1834- /// [rustdoc book]: ../../../rustdoc/lints.html#broken_intra_doc_links
1834+ /// [rustdoc book]: ../../../rustdoc/lints.html#private_intra_doc_links
18351835 pub PRIVATE_INTRA_DOC_LINKS ,
18361836 Warn ,
18371837 "linking from a public item to a private one"
Original file line number Diff line number Diff line change @@ -62,6 +62,46 @@ help: to link to the function, add parentheses
6262
6363```
6464
65+ ## private_intra_doc_links
66+
67+ This lint ** warns by default** . This lint detects when [ intra-doc links] from public to private items.
68+ For example:
69+
70+ ``` rust
71+ /// [private]
72+ pub fn public () {}
73+ fn private () {}
74+ ```
75+
76+ This gives a warning that the link will be broken when it appears in your documentation:
77+
78+ ``` text
79+ warning: public documentation for `public` links to private item `private`
80+ --> priv.rs:1:6
81+ |
82+ 1 | /// [private]
83+ | ^^^^^^^ this item is private
84+ |
85+ = note: `#[warn(private_intra_doc_links)]` on by default
86+ = note: this link will resolve properly if you pass `--document-private-items`
87+ ```
88+
89+ Note that this has different behavior depending on whether you pass ` --document-private-items ` or not!
90+ If you document private items, then it will still generate a link, despite the warning:
91+
92+ ``` text
93+ warning: public documentation for `public` links to private item `private`
94+ --> priv.rs:1:6
95+ |
96+ 1 | /// [private]
97+ | ^^^^^^^ this item is private
98+ |
99+ = note: `#[warn(private_intra_doc_links)]` on by default
100+ = note: this link resolves only because you passed `--document-private-items`, but will break without
101+ ```
102+
103+ [ intra-doc links ] : linking-to-items-by-name.html
104+
65105## missing_docs
66106
67107This lint is ** allowed by default** . It detects items missing documentation.
You can’t perform that action at this time.
0 commit comments