Add regression tests for #130233
This commit is contained in:
parent
73fc00ff8c
commit
d540e7285c
15
tests/rustdoc-ui/intra-doc/filter-out-private-2.rs
Normal file
15
tests/rustdoc-ui/intra-doc/filter-out-private-2.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// This test ensures that ambiguities (not) resolved at a later stage still emit an error.
|
||||||
|
|
||||||
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub struct Thing {}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn Thing() {}
|
||||||
|
|
||||||
|
/// Do stuff with [`Thing`].
|
||||||
|
//~^ ERROR all items matching `Thing` are either private or doc(hidden)
|
||||||
|
pub fn repro(_: Thing) {}
|
14
tests/rustdoc-ui/intra-doc/filter-out-private-2.stderr
Normal file
14
tests/rustdoc-ui/intra-doc/filter-out-private-2.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
error: all items matching `Thing` are either private or doc(hidden)
|
||||||
|
--> $DIR/filter-out-private-2.rs:13:21
|
||||||
|
|
|
||||||
|
LL | /// Do stuff with [`Thing`].
|
||||||
|
| ^^^^^ unresolved link
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/filter-out-private-2.rs:3:9
|
||||||
|
|
|
||||||
|
LL | #![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
13
tests/rustdoc-ui/intra-doc/filter-out-private.rs
Normal file
13
tests/rustdoc-ui/intra-doc/filter-out-private.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// This test ensures that ambiguities resolved at a later stage still emit an error.
|
||||||
|
|
||||||
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
pub struct Thing {}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn Thing() {}
|
||||||
|
|
||||||
|
/// Do stuff with [`Thing`].
|
||||||
|
//~^ ERROR `Thing` is both a function and a struct
|
||||||
|
pub fn repro(_: Thing) {}
|
22
tests/rustdoc-ui/intra-doc/filter-out-private.stderr
Normal file
22
tests/rustdoc-ui/intra-doc/filter-out-private.stderr
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
error: `Thing` is both a function and a struct
|
||||||
|
--> $DIR/filter-out-private.rs:11:21
|
||||||
|
|
|
||||||
|
LL | /// Do stuff with [`Thing`].
|
||||||
|
| ^^^^^ ambiguous link
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/filter-out-private.rs:3:9
|
||||||
|
|
|
||||||
|
LL | #![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
help: to link to the function, add parentheses
|
||||||
|
|
|
||||||
|
LL | /// Do stuff with [`Thing()`].
|
||||||
|
| ++
|
||||||
|
help: to link to the struct, prefix with `struct@`
|
||||||
|
|
|
||||||
|
LL | /// Do stuff with [`struct@Thing`].
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
26
tests/rustdoc/intra-doc/filter-out-private.rs
Normal file
26
tests/rustdoc/intra-doc/filter-out-private.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// This test ensures that private/hidden items don't create ambiguity.
|
||||||
|
// This is a regression test for <https://github.com/rust-lang/rust/issues/130233>.
|
||||||
|
|
||||||
|
#![deny(rustdoc::broken_intra_doc_links)]
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
pub struct Thing {}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn Thing() {}
|
||||||
|
|
||||||
|
pub struct Bar {}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
fn Bar() {}
|
||||||
|
|
||||||
|
//@ has 'foo/fn.repro.html'
|
||||||
|
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]//a/@href' 'struct.Thing.html'
|
||||||
|
/// Do stuff with [`Thing`].
|
||||||
|
pub fn repro(_: Thing) {}
|
||||||
|
|
||||||
|
//@ has 'foo/fn.repro2.html'
|
||||||
|
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]//a/@href' 'struct.Bar.html'
|
||||||
|
/// Do stuff with [`Bar`].
|
||||||
|
pub fn repro2(_: Bar) {}
|
Loading…
Reference in New Issue
Block a user