Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2964,9 +2964,14 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
let mut mod_inner_attrs_start = None;
match item.kind {
ItemKind::Mod(..) => {
// We only handle outer doc comments for modules here.
// We only handle outer attributes which can contain intra-doc links (doc comments
// and `deprecated`) for modules here.
let attrs = if let Some(pos) = item.attrs.iter().position(|a| {
a.doc_resolution_scope().is_some_and(|style| style == AttrStyle::Inner)
|| matches!(
a.kind,
AttrKind::Normal(ref n)
if n.item.name() == Some(sym::deprecated) && a.style == AttrStyle::Inner)
}) {
mod_inner_attrs_start = Some(pos);
&item.attrs[..pos]
Expand Down
15 changes: 15 additions & 0 deletions tests/rustdoc-ui/intra-doc/link-in-deprecation-note-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Because inner and outer attributes don't have the same scope for a module, we need
// to also apply the logic to the other module attributes which can contain intra-doc
// links.
// Regression test for <https://github.com/rust-lang/rust/issues/164711>.

#![deny(rustdoc::broken_intra_doc_links)]

pub mod a {
#![deprecated = "[](TypeAlias::x)"]
//~^ ERROR broken_intra_doc_links
}

#[deprecated = "[](TypeAlias::x)"]
//~^ ERROR broken_intra_doc_links
pub mod b {}
31 changes: 31 additions & 0 deletions tests/rustdoc-ui/intra-doc/link-in-deprecation-note-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error: unresolved link to `TypeAlias::x`
--> $DIR/link-in-deprecation-note-2.rs:9:21
|
LL | #![deprecated = "[](TypeAlias::x)"]
| ^^^^^^^^^^^^^^^^^^
|
= note: the link appears in this line:

[](TypeAlias::x)
^^^^^^^^^^^^
= note: no item named `TypeAlias` in scope
note: the lint level is defined here
--> $DIR/link-in-deprecation-note-2.rs:6:9
|
LL | #![deny(rustdoc::broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unresolved link to `TypeAlias::x`
--> $DIR/link-in-deprecation-note-2.rs:13:16
|
LL | #[deprecated = "[](TypeAlias::x)"]
| ^^^^^^^^^^^^^^^^^^
|
= note: the link appears in this line:

[](TypeAlias::x)
^^^^^^^^^^^^
= note: no item named `TypeAlias` in scope

error: aborting due to 2 previous errors

Loading