Skip to content

Commit d59f4ae

Browse files
committed
add test for new rustdoc::hidden_intra_doc_links lint
1 parent 70dd729 commit d59f4ae

File tree

6 files changed

+327
-0
lines changed

6 files changed

+327
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[doc(hidden)]
2+
pub fn public_hidden_fn() {}
3+
4+
#[doc(hidden)]
5+
fn private_hidden_fn() {}
6+
7+
pub fn public_non_hidden_fn() {}
8+
9+
fn private_non_hidden_fn() {}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_public_hidden_fn`
2+
--> $DIR/link-to-hidden-144664.rs:14:8
3+
|
4+
LL | //! * [crate::local_public_hidden_fn]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
6+
|
7+
= note: this link resolves only because you passed `--document-hidden-items`, but will break without
8+
note: the lint level is defined here
9+
--> $DIR/link-to-hidden-144664.rs:10:9
10+
|
11+
LL | #![deny(rustdoc::hidden_intra_doc_links)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_hidden_fn`
15+
--> $DIR/link-to-hidden-144664.rs:16:8
16+
|
17+
LL | //! * [crate::local_private_hidden_fn]
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
19+
|
20+
= note: this link resolves only because you passed `--document-private-items`, but will break without
21+
note: the lint level is defined here
22+
--> $DIR/link-to-hidden-144664.rs:9:9
23+
|
24+
LL | #![deny(rustdoc::private_intra_doc_links)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_private_hidden_fn`
28+
--> $DIR/link-to-hidden-144664.rs:16:8
29+
|
30+
LL | //! * [crate::local_private_hidden_fn]
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
32+
|
33+
= note: this link resolves only because you passed `--document-hidden-items`, but will break without
34+
35+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_non_hidden_fn`
36+
--> $DIR/link-to-hidden-144664.rs:19:8
37+
|
38+
LL | //! * [crate::local_private_non_hidden_fn]
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
40+
|
41+
= note: this link resolves only because you passed `--document-private-items`, but will break without
42+
43+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `nonlocal::public_hidden_fn`
44+
--> $DIR/link-to-hidden-144664.rs:21:8
45+
|
46+
LL | //! * [nonlocal::public_hidden_fn]
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
48+
|
49+
= note: this link resolves only because you passed `--document-hidden-items`, but will break without
50+
51+
error: unresolved link to `nonlocal::private_hidden_fn`
52+
--> $DIR/link-to-hidden-144664.rs:24:8
53+
|
54+
LL | //! * [nonlocal::private_hidden_fn]
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_hidden_fn` in module `hidden`
56+
|
57+
note: the lint level is defined here
58+
--> $DIR/link-to-hidden-144664.rs:11:9
59+
|
60+
LL | #![deny(rustdoc::broken_intra_doc_links)]
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
63+
error: unresolved link to `nonlocal::private_non_hidden_fn`
64+
--> $DIR/link-to-hidden-144664.rs:26:8
65+
|
66+
LL | //! * [nonlocal::private_non_hidden_fn]
67+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_non_hidden_fn` in module `hidden`
68+
69+
error: aborting due to 7 previous errors
70+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_public_hidden_fn`
2+
--> $DIR/link-to-hidden-144664.rs:14:8
3+
|
4+
LL | //! * [crate::local_public_hidden_fn]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
6+
|
7+
= note: this link will resolve properly if you pass `--document-hidden-items`
8+
note: the lint level is defined here
9+
--> $DIR/link-to-hidden-144664.rs:10:9
10+
|
11+
LL | #![deny(rustdoc::hidden_intra_doc_links)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_hidden_fn`
15+
--> $DIR/link-to-hidden-144664.rs:16:8
16+
|
17+
LL | //! * [crate::local_private_hidden_fn]
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
19+
|
20+
= note: this link will resolve properly if you pass `--document-private-items`
21+
note: the lint level is defined here
22+
--> $DIR/link-to-hidden-144664.rs:9:9
23+
|
24+
LL | #![deny(rustdoc::private_intra_doc_links)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_private_hidden_fn`
28+
--> $DIR/link-to-hidden-144664.rs:16:8
29+
|
30+
LL | //! * [crate::local_private_hidden_fn]
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
32+
|
33+
= note: this link will resolve properly if you pass `--document-hidden-items`
34+
35+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_non_hidden_fn`
36+
--> $DIR/link-to-hidden-144664.rs:19:8
37+
|
38+
LL | //! * [crate::local_private_non_hidden_fn]
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
40+
|
41+
= note: this link will resolve properly if you pass `--document-private-items`
42+
43+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `nonlocal::public_hidden_fn`
44+
--> $DIR/link-to-hidden-144664.rs:21:8
45+
|
46+
LL | //! * [nonlocal::public_hidden_fn]
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
48+
|
49+
= note: this link will resolve properly if you pass `--document-hidden-items`
50+
51+
error: unresolved link to `nonlocal::private_hidden_fn`
52+
--> $DIR/link-to-hidden-144664.rs:24:8
53+
|
54+
LL | //! * [nonlocal::private_hidden_fn]
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_hidden_fn` in module `hidden`
56+
|
57+
note: the lint level is defined here
58+
--> $DIR/link-to-hidden-144664.rs:11:9
59+
|
60+
LL | #![deny(rustdoc::broken_intra_doc_links)]
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
63+
error: unresolved link to `nonlocal::private_non_hidden_fn`
64+
--> $DIR/link-to-hidden-144664.rs:26:8
65+
|
66+
LL | //! * [nonlocal::private_non_hidden_fn]
67+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_non_hidden_fn` in module `hidden`
68+
69+
error: aborting due to 7 previous errors
70+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_public_hidden_fn`
2+
--> $DIR/link-to-hidden-144664.rs:14:8
3+
|
4+
LL | //! * [crate::local_public_hidden_fn]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
6+
|
7+
= note: this link resolves only because you passed `--document-hidden-items`, but will break without
8+
note: the lint level is defined here
9+
--> $DIR/link-to-hidden-144664.rs:10:9
10+
|
11+
LL | #![deny(rustdoc::hidden_intra_doc_links)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_hidden_fn`
15+
--> $DIR/link-to-hidden-144664.rs:16:8
16+
|
17+
LL | //! * [crate::local_private_hidden_fn]
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
19+
|
20+
= note: this link resolves only because you passed `--document-private-items`, but will break without
21+
note: the lint level is defined here
22+
--> $DIR/link-to-hidden-144664.rs:9:9
23+
|
24+
LL | #![deny(rustdoc::private_intra_doc_links)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_private_hidden_fn`
28+
--> $DIR/link-to-hidden-144664.rs:16:8
29+
|
30+
LL | //! * [crate::local_private_hidden_fn]
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
32+
|
33+
= note: this link resolves only because you passed `--document-hidden-items`, but will break without
34+
35+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_non_hidden_fn`
36+
--> $DIR/link-to-hidden-144664.rs:19:8
37+
|
38+
LL | //! * [crate::local_private_non_hidden_fn]
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
40+
|
41+
= note: this link resolves only because you passed `--document-private-items`, but will break without
42+
43+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `nonlocal::public_hidden_fn`
44+
--> $DIR/link-to-hidden-144664.rs:21:8
45+
|
46+
LL | //! * [nonlocal::public_hidden_fn]
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
48+
|
49+
= note: this link resolves only because you passed `--document-hidden-items`, but will break without
50+
51+
error: unresolved link to `nonlocal::private_hidden_fn`
52+
--> $DIR/link-to-hidden-144664.rs:24:8
53+
|
54+
LL | //! * [nonlocal::private_hidden_fn]
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_hidden_fn` in module `hidden`
56+
|
57+
note: the lint level is defined here
58+
--> $DIR/link-to-hidden-144664.rs:11:9
59+
|
60+
LL | #![deny(rustdoc::broken_intra_doc_links)]
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
63+
error: unresolved link to `nonlocal::private_non_hidden_fn`
64+
--> $DIR/link-to-hidden-144664.rs:26:8
65+
|
66+
LL | //! * [nonlocal::private_non_hidden_fn]
67+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_non_hidden_fn` in module `hidden`
68+
69+
error: aborting due to 7 previous errors
70+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_public_hidden_fn`
2+
--> $DIR/link-to-hidden-144664.rs:14:8
3+
|
4+
LL | //! * [crate::local_public_hidden_fn]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
6+
|
7+
= note: this link will resolve properly if you pass `--document-hidden-items`
8+
note: the lint level is defined here
9+
--> $DIR/link-to-hidden-144664.rs:10:9
10+
|
11+
LL | #![deny(rustdoc::hidden_intra_doc_links)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_hidden_fn`
15+
--> $DIR/link-to-hidden-144664.rs:16:8
16+
|
17+
LL | //! * [crate::local_private_hidden_fn]
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
19+
|
20+
= note: this link will resolve properly if you pass `--document-private-items`
21+
note: the lint level is defined here
22+
--> $DIR/link-to-hidden-144664.rs:9:9
23+
|
24+
LL | #![deny(rustdoc::private_intra_doc_links)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_private_hidden_fn`
28+
--> $DIR/link-to-hidden-144664.rs:16:8
29+
|
30+
LL | //! * [crate::local_private_hidden_fn]
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
32+
|
33+
= note: this link will resolve properly if you pass `--document-hidden-items`
34+
35+
error: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_non_hidden_fn`
36+
--> $DIR/link-to-hidden-144664.rs:19:8
37+
|
38+
LL | //! * [crate::local_private_non_hidden_fn]
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is private
40+
|
41+
= note: this link will resolve properly if you pass `--document-private-items`
42+
43+
error: non-hidden documentation for `link_to_hidden_144664` links to hidden item `nonlocal::public_hidden_fn`
44+
--> $DIR/link-to-hidden-144664.rs:21:8
45+
|
46+
LL | //! * [nonlocal::public_hidden_fn]
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this item is hidden
48+
|
49+
= note: this link will resolve properly if you pass `--document-hidden-items`
50+
51+
error: unresolved link to `nonlocal::private_hidden_fn`
52+
--> $DIR/link-to-hidden-144664.rs:24:8
53+
|
54+
LL | //! * [nonlocal::private_hidden_fn]
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_hidden_fn` in module `hidden`
56+
|
57+
note: the lint level is defined here
58+
--> $DIR/link-to-hidden-144664.rs:11:9
59+
|
60+
LL | #![deny(rustdoc::broken_intra_doc_links)]
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
63+
error: unresolved link to `nonlocal::private_non_hidden_fn`
64+
--> $DIR/link-to-hidden-144664.rs:26:8
65+
|
66+
LL | //! * [nonlocal::private_non_hidden_fn]
67+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `private_non_hidden_fn` in module `hidden`
68+
69+
error: aborting due to 7 previous errors
70+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//@ revisions: noflags doc-priv doc-hidden doc-both
2+
//@ aux-build: hidden.rs
3+
//@ build-aux-docs
4+
//@[doc-priv]compile-flags: --document-private-items
5+
//@[doc-hidden]compile-flags: -Z unstable-options --document-hidden-items
6+
//@[doc-both]compile-flags: -Z unstable-options --document-hidden-items --document-private-items
7+
8+
#![deny(rustdoc::private_intra_doc_links)]
9+
#![deny(rustdoc::hidden_intra_doc_links)]
10+
#![deny(rustdoc::broken_intra_doc_links)]
11+
12+
//! All these links are broken and should produce warnings:
13+
//! * [crate::local_public_hidden_fn]
14+
//~^ ERROR: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_public_hidden_fn`
15+
16+
// for local items that are hidden and private, both lints are emmitted
17+
//! * [crate::local_private_hidden_fn]
18+
//~^ ERROR: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_hidden_fn`
19+
//~| ERROR: non-hidden documentation for `link_to_hidden_144664` links to hidden item `crate::local_private_hidden_fn`
20+
21+
//! * [crate::local_private_non_hidden_fn]
22+
//~^ ERROR: public documentation for `link_to_hidden_144664` links to private item `crate::local_private_non_hidden_fn`
23+
//! * [nonlocal::public_hidden_fn]
24+
//~^ ERROR: non-hidden documentation for `link_to_hidden_144664` links to hidden item `nonlocal::public_hidden_fn`
25+
26+
// for cross-crate private items, rustdoc doesn't even know if they exist, so we get a generic error.
27+
//! * [nonlocal::private_hidden_fn]
28+
//~^ ERROR: unresolved link
29+
//! * [nonlocal::private_non_hidden_fn]
30+
//~^ ERROR: unresolved link
31+
extern crate hidden as nonlocal;
32+
33+
#[doc(hidden)] pub fn local_public_hidden_fn() {}
34+
#[doc(hidden)] fn local_private_hidden_fn() {}
35+
pub fn local_public_non_hidden_fn() {}
36+
fn local_private_non_hidden_fn() {}
37+
38+
// FIXME: lint for items that are within hidden modules also

0 commit comments

Comments
 (0)