Skip to content

Commit 5e8b79b

Browse files
Add ui test for redundant_explicit_links rustdoc lint for items coming from expansion
1 parent 6032ce1 commit 5e8b79b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This is a regression test for <https://github.com/rust-lang/rust/issues/141553>.
2+
// If the link is generated from expansion, we should not emit the lint.
3+
4+
#![deny(rustdoc::redundant_explicit_links)]
5+
6+
macro_rules! mac1 {
7+
() => {
8+
"provided by a [`BufferProvider`](crate::BufferProvider)."
9+
};
10+
}
11+
12+
macro_rules! mac2 {
13+
() => {
14+
#[doc = mac1!()]
15+
pub struct BufferProvider;
16+
}
17+
}
18+
19+
// Should not lint.
20+
#[doc = mac1!()]
21+
pub struct Foo;
22+
23+
// Should not lint.
24+
mac2!{}
25+
26+
#[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."]
27+
//~^ ERROR: redundant_explicit_links
28+
pub struct Bla;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: redundant explicit link target
2+
--> $DIR/redundant_explicit_links-expansion.rs:26:43
3+
|
4+
LL | #[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."]
5+
| ---------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant
6+
| |
7+
| because label contains path that resolves to same destination
8+
|
9+
= note: when a link's destination is not specified,
10+
the label is used to resolve intra-doc links
11+
note: the lint level is defined here
12+
--> $DIR/redundant_explicit_links-expansion.rs:4:9
13+
|
14+
LL | #![deny(rustdoc::redundant_explicit_links)]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
help: remove explicit link target
17+
|
18+
LL - #[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."]
19+
LL + #[doc = "provided by a [`BufferProvider`]."]
20+
|
21+
22+
error: aborting due to 1 previous error
23+

0 commit comments

Comments
 (0)