Skip to content

Commit d540e72

Browse files
Add regression tests for rust-lang#130233
1 parent 73fc00f commit d540e72

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This test ensures that ambiguities (not) resolved at a later stage still emit an error.
2+
3+
#![deny(rustdoc::broken_intra_doc_links)]
4+
#![crate_name = "foo"]
5+
6+
#[doc(hidden)]
7+
pub struct Thing {}
8+
9+
#[allow(non_snake_case)]
10+
#[doc(hidden)]
11+
pub fn Thing() {}
12+
13+
/// Do stuff with [`Thing`].
14+
//~^ ERROR all items matching `Thing` are either private or doc(hidden)
15+
pub fn repro(_: Thing) {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: all items matching `Thing` are either private or doc(hidden)
2+
--> $DIR/filter-out-private-2.rs:13:21
3+
|
4+
LL | /// Do stuff with [`Thing`].
5+
| ^^^^^ unresolved link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/filter-out-private-2.rs:3:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This test ensures that ambiguities resolved at a later stage still emit an error.
2+
3+
#![deny(rustdoc::broken_intra_doc_links)]
4+
#![crate_name = "foo"]
5+
6+
pub struct Thing {}
7+
8+
#[allow(non_snake_case)]
9+
pub fn Thing() {}
10+
11+
/// Do stuff with [`Thing`].
12+
//~^ ERROR `Thing` is both a function and a struct
13+
pub fn repro(_: Thing) {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: `Thing` is both a function and a struct
2+
--> $DIR/filter-out-private.rs:11:21
3+
|
4+
LL | /// Do stuff with [`Thing`].
5+
| ^^^^^ ambiguous link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/filter-out-private.rs:3:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the function, add parentheses
13+
|
14+
LL | /// Do stuff with [`Thing()`].
15+
| ++
16+
help: to link to the struct, prefix with `struct@`
17+
|
18+
LL | /// Do stuff with [`struct@Thing`].
19+
| +++++++
20+
21+
error: aborting due to 1 previous error
22+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This test ensures that private/hidden items don't create ambiguity.
2+
// This is a regression test for <https://github.com/rust-lang/rust/issues/130233>.
3+
4+
#![deny(rustdoc::broken_intra_doc_links)]
5+
#![crate_name = "foo"]
6+
7+
pub struct Thing {}
8+
9+
#[doc(hidden)]
10+
#[allow(non_snake_case)]
11+
pub fn Thing() {}
12+
13+
pub struct Bar {}
14+
15+
#[allow(non_snake_case)]
16+
fn Bar() {}
17+
18+
//@ has 'foo/fn.repro.html'
19+
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]//a/@href' 'struct.Thing.html'
20+
/// Do stuff with [`Thing`].
21+
pub fn repro(_: Thing) {}
22+
23+
//@ has 'foo/fn.repro2.html'
24+
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]//a/@href' 'struct.Bar.html'
25+
/// Do stuff with [`Bar`].
26+
pub fn repro2(_: Bar) {}

0 commit comments

Comments
 (0)