rustdoc: check redundant explicit links with correct itemid
Fixes a regression caused by 0a50dba50b
This commit is contained in:
parent
c8d9753668
commit
0fea38a01f
2 changed files with 22 additions and 11 deletions
|
@ -6,7 +6,7 @@ use rustc_errors::SuggestionStyle;
|
||||||
use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res};
|
use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res};
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
use rustc_lint_defs::Applicability;
|
use rustc_lint_defs::Applicability;
|
||||||
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, source_span_for_markdown_range};
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
|
@ -29,16 +29,13 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let doc = item.doc_value();
|
let hunks = prepare_to_doc_link_resolution(&item.attrs.doc_strings);
|
||||||
if doc.is_empty() {
|
for (item_id, doc) in hunks {
|
||||||
return;
|
if let Some(item_id) = item_id.or(item.def_id())
|
||||||
}
|
&& !doc.is_empty()
|
||||||
|
{
|
||||||
if let Some(item_id) = item.def_id() {
|
check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc);
|
||||||
check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc);
|
}
|
||||||
}
|
|
||||||
if let Some(item_id) = item.inline_stmt_id {
|
|
||||||
check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
tests/rustdoc-ui/redundant-explicit-links-123677.rs
Normal file
14
tests/rustdoc-ui/redundant-explicit-links-123677.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
//@ check-pass
|
||||||
|
#![deny(rustdoc::redundant_explicit_links)]
|
||||||
|
|
||||||
|
mod bar {
|
||||||
|
/// [`Rc`](std::rc::Rc)
|
||||||
|
pub enum Baz {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use bar::*;
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
/// [`Rc::allocator`] [foo](std::rc::Rc)
|
||||||
|
pub fn winit_runner() {}
|
Loading…
Add table
Add a link
Reference in a new issue