Skip to content

Commit d673776

Browse files
Rollup merge of #164733 - GuillaumeGomez:deprecated-doc-resolution, r=Urgau
Include `deprecated` attributes in `rustc_resolve` intra-doc link resolution Fixes #164711. Problem was that we didn't include `deprecated` attribute in the "inner" marker, so it was never processed in `rustc_resolve` and therefore couldn't be found in rustdoc intra-doc link handling. r? @Urgau
2 parents 30d6b5e + c4016d0 commit d673776

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

‎compiler/rustc_resolve/src/late.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2964,9 +2964,14 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
29642964
let mut mod_inner_attrs_start = None;
29652965
match item.kind {
29662966
ItemKind::Mod(..) => {
2967-
// We only handle outer doc comments for modules here.
2967+
// We only handle outer attributes which can contain intra-doc links (doc comments
2968+
// and `deprecated`) for modules here.
29682969
let attrs = if let Some(pos) = item.attrs.iter().position(|a| {
29692970
a.doc_resolution_scope().is_some_and(|style| style == AttrStyle::Inner)
2971+
|| matches!(
2972+
a.kind,
2973+
AttrKind::Normal(ref n)
2974+
if n.item.name() == Some(sym::deprecated) && a.style == AttrStyle::Inner)
29702975
}) {
29712976
mod_inner_attrs_start = Some(pos);
29722977
&item.attrs[..pos]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Because inner and outer attributes don't have the same scope for a module, we need
2+
// to also apply the logic to the other module attributes which can contain intra-doc
3+
// links.
4+
// Regression test for <https://github.com/rust-lang/rust/issues/164711>.
5+
6+
#![deny(rustdoc::broken_intra_doc_links)]
7+
8+
pub mod a {
9+
#![deprecated = "[](TypeAlias::x)"]
10+
//~^ ERROR broken_intra_doc_links
11+
}
12+
13+
#[deprecated = "[](TypeAlias::x)"]
14+
//~^ ERROR broken_intra_doc_links
15+
pub mod b {}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: unresolved link to `TypeAlias::x`
2+
--> $DIR/link-in-deprecation-note-2.rs:9:21
3+
|
4+
LL | #![deprecated = "[](TypeAlias::x)"]
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: the link appears in this line:
8+
9+
[](TypeAlias::x)
10+
^^^^^^^^^^^^
11+
= note: no item named `TypeAlias` in scope
12+
note: the lint level is defined here
13+
--> $DIR/link-in-deprecation-note-2.rs:6:9
14+
|
15+
LL | #![deny(rustdoc::broken_intra_doc_links)]
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
18+
error: unresolved link to `TypeAlias::x`
19+
--> $DIR/link-in-deprecation-note-2.rs:13:16
20+
|
21+
LL | #[deprecated = "[](TypeAlias::x)"]
22+
| ^^^^^^^^^^^^^^^^^^
23+
|
24+
= note: the link appears in this line:
25+
26+
[](TypeAlias::x)
27+
^^^^^^^^^^^^
28+
= note: no item named `TypeAlias` in scope
29+
30+
error: aborting due to 2 previous errors
31+

0 commit comments

Comments
 (0)