Add ui test for redundant_explicit_links rustdoc lint for items coming from expansion

This commit is contained in:
Guillaume Gomez
2025-05-27 15:17:22 +02:00
parent 7e683cc4d1
commit a0d64177f0
2 changed files with 51 additions and 0 deletions
@@ -0,0 +1,28 @@
// This is a regression test for <https://github.com/rust-lang/rust/issues/141553>.
// If the link is generated from expansion, we should not emit the lint.
#![deny(rustdoc::redundant_explicit_links)]
macro_rules! mac1 {
() => {
"provided by a [`BufferProvider`](crate::BufferProvider)."
};
}
macro_rules! mac2 {
() => {
#[doc = mac1!()]
pub struct BufferProvider;
}
}
// Should not lint.
#[doc = mac1!()]
pub struct Foo;
// Should not lint.
mac2!{}
#[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."]
//~^ ERROR: redundant_explicit_links
pub struct Bla;
@@ -0,0 +1,23 @@
error: redundant explicit link target
--> $DIR/redundant_explicit_links-expansion.rs:26:43
|
LL | #[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."]
| ---------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant
| |
| because label contains path that resolves to same destination
|
= note: when a link's destination is not specified,
the label is used to resolve intra-doc links
note: the lint level is defined here
--> $DIR/redundant_explicit_links-expansion.rs:4:9
|
LL | #![deny(rustdoc::redundant_explicit_links)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: remove explicit link target
|
LL - #[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."]
LL + #[doc = "provided by a [`BufferProvider`]."]
|
error: aborting due to 1 previous error