Skip to content

Commit 364033c

Browse files
authored
Unrolled build for rust-lang#123905
Rollup merge of rust-lang#123905 - notriddle:notriddle/redundant-explicit-link-hunks, r=GuillaumeGomez rustdoc: check redundant explicit links with correct itemid Fixes rust-lang#123677 (a regression caused by rust-lang#120702)
2 parents 29b1207 + 0fea38a commit 364033c

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/librustdoc/passes/lint/redundant_explicit_links.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_errors::SuggestionStyle;
66
use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res};
77
use rustc_hir::HirId;
88
use rustc_lint_defs::Applicability;
9-
use rustc_resolve::rustdoc::source_span_for_markdown_range;
9+
use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, source_span_for_markdown_range};
1010
use rustc_span::def_id::DefId;
1111
use rustc_span::Symbol;
1212

@@ -29,16 +29,13 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
2929
return;
3030
};
3131

32-
let doc = item.doc_value();
33-
if doc.is_empty() {
34-
return;
35-
}
36-
37-
if let Some(item_id) = item.def_id() {
38-
check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc);
39-
}
40-
if let Some(item_id) = item.inline_stmt_id {
41-
check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc);
32+
let hunks = prepare_to_doc_link_resolution(&item.attrs.doc_strings);
33+
for (item_id, doc) in hunks {
34+
if let Some(item_id) = item_id.or(item.def_id())
35+
&& !doc.is_empty()
36+
{
37+
check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc);
38+
}
4239
}
4340
}
4441

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ check-pass
2+
#![deny(rustdoc::redundant_explicit_links)]
3+
4+
mod bar {
5+
/// [`Rc`](std::rc::Rc)
6+
pub enum Baz {}
7+
}
8+
9+
pub use bar::*;
10+
11+
use std::rc::Rc;
12+
13+
/// [`Rc::allocator`] [foo](std::rc::Rc)
14+
pub fn winit_runner() {}

0 commit comments

Comments
 (0)