@@ -33,13 +33,6 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
33
33
return ;
34
34
}
35
35
36
- if item. link_names ( & cx. cache ) . is_empty ( ) {
37
- // If there's no link names in this item,
38
- // then we skip resolution querying to
39
- // avoid from panicking.
40
- return ;
41
- }
42
-
43
36
let Some ( item_id) = item. def_id ( ) else {
44
37
return ;
45
38
} ;
@@ -58,14 +51,29 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
58
51
return ;
59
52
}
60
53
61
- check_redundant_explicit_link ( cx, item, hir_id, & doc) ;
54
+ let module_id = match cx. tcx . def_kind ( item_id) {
55
+ DefKind :: Mod if item. inner_docs ( cx. tcx ) => item_id,
56
+ _ => find_nearest_parent_module ( cx. tcx , item_id) . unwrap ( ) ,
57
+ } ;
58
+
59
+ let Some ( resolutions) =
60
+ cx. tcx . resolutions ( ( ) ) . doc_link_resolutions . get ( & module_id. expect_local ( ) )
61
+ else {
62
+ // If there's no resolutions in this module,
63
+ // then we skip resolution querying to
64
+ // avoid from panicking.
65
+ return ;
66
+ } ;
67
+
68
+ check_redundant_explicit_link ( cx, item, hir_id, & doc, & resolutions) ;
62
69
}
63
70
64
71
fn check_redundant_explicit_link < ' md > (
65
72
cx : & DocContext < ' _ > ,
66
73
item : & Item ,
67
74
hir_id : HirId ,
68
75
doc : & ' md str ,
76
+ resolutions : & DocLinkResMap ,
69
77
) -> Option < ( ) > {
70
78
let mut broken_line_callback = |link : BrokenLink < ' md > | Some ( ( link. reference , "" . into ( ) ) ) ;
71
79
let mut offset_iter = Parser :: new_with_broken_link_callback (
@@ -74,12 +82,6 @@ fn check_redundant_explicit_link<'md>(
74
82
Some ( & mut broken_line_callback) ,
75
83
)
76
84
. into_offset_iter ( ) ;
77
- let item_id = item. def_id ( ) ?;
78
- let module_id = match cx. tcx . def_kind ( item_id) {
79
- DefKind :: Mod if item. inner_docs ( cx. tcx ) => item_id,
80
- _ => find_nearest_parent_module ( cx. tcx , item_id) . unwrap ( ) ,
81
- } ;
82
- let resolutions = cx. tcx . doc_link_resolutions ( module_id) ;
83
85
84
86
while let Some ( ( event, link_range) ) = offset_iter. next ( ) {
85
87
match event {
0 commit comments