@@ -6,14 +6,14 @@ use rustc_errors::SuggestionStyle;
6
6
use rustc_hir:: def:: { DefKind , DocLinkResMap , Namespace , Res } ;
7
7
use rustc_hir:: HirId ;
8
8
use rustc_lint_defs:: Applicability ;
9
+ use rustc_resolve:: rustdoc:: source_span_for_markdown_range;
9
10
use rustc_span:: Symbol ;
10
11
11
12
use crate :: clean:: utils:: find_nearest_parent_module;
12
13
use crate :: clean:: utils:: inherits_doc_hidden;
13
14
use crate :: clean:: Item ;
14
15
use crate :: core:: DocContext ;
15
16
use crate :: html:: markdown:: main_body_opts;
16
- use crate :: passes:: source_span_for_markdown_range;
17
17
18
18
#[ derive( Debug ) ]
19
19
struct LinkData {
@@ -160,16 +160,21 @@ fn check_inline_or_reference_unknown_redundancy(
160
160
( find_resolution ( resolutions, & dest) ?, find_resolution ( resolutions, resolvable_link) ?) ;
161
161
162
162
if dest_res == display_res {
163
- let link_span = source_span_for_markdown_range ( cx. tcx , & doc, & link_range, & item. attrs )
164
- . unwrap_or ( item. attr_span ( cx. tcx ) ) ;
163
+ let link_span =
164
+ source_span_for_markdown_range ( cx. tcx , & doc, & link_range, & item. attrs . doc_strings )
165
+ . unwrap_or ( item. attr_span ( cx. tcx ) ) ;
165
166
let explicit_span = source_span_for_markdown_range (
166
167
cx. tcx ,
167
168
& doc,
168
169
& offset_explicit_range ( doc, link_range, open, close) ,
169
- & item. attrs ,
170
+ & item. attrs . doc_strings ,
171
+ ) ?;
172
+ let display_span = source_span_for_markdown_range (
173
+ cx. tcx ,
174
+ & doc,
175
+ & resolvable_link_range,
176
+ & item. attrs . doc_strings ,
170
177
) ?;
171
- let display_span =
172
- source_span_for_markdown_range ( cx. tcx , & doc, & resolvable_link_range, & item. attrs ) ?;
173
178
174
179
cx. tcx . struct_span_lint_hir ( crate :: lint:: REDUNDANT_EXPLICIT_LINKS , hir_id, explicit_span, "redundant explicit link target" , |lint| {
175
180
lint. span_label ( explicit_span, "explicit target is redundant" )
@@ -201,21 +206,26 @@ fn check_reference_redundancy(
201
206
( find_resolution ( resolutions, & dest) ?, find_resolution ( resolutions, resolvable_link) ?) ;
202
207
203
208
if dest_res == display_res {
204
- let link_span = source_span_for_markdown_range ( cx. tcx , & doc, & link_range, & item. attrs )
205
- . unwrap_or ( item. attr_span ( cx. tcx ) ) ;
209
+ let link_span =
210
+ source_span_for_markdown_range ( cx. tcx , & doc, & link_range, & item. attrs . doc_strings )
211
+ . unwrap_or ( item. attr_span ( cx. tcx ) ) ;
206
212
let explicit_span = source_span_for_markdown_range (
207
213
cx. tcx ,
208
214
& doc,
209
215
& offset_explicit_range ( doc, link_range. clone ( ) , b'[' , b']' ) ,
210
- & item. attrs ,
216
+ & item. attrs . doc_strings ,
217
+ ) ?;
218
+ let display_span = source_span_for_markdown_range (
219
+ cx. tcx ,
220
+ & doc,
221
+ & resolvable_link_range,
222
+ & item. attrs . doc_strings ,
211
223
) ?;
212
- let display_span =
213
- source_span_for_markdown_range ( cx. tcx , & doc, & resolvable_link_range, & item. attrs ) ?;
214
224
let def_span = source_span_for_markdown_range (
215
225
cx. tcx ,
216
226
& doc,
217
227
& offset_reference_def_range ( doc, dest, link_range) ,
218
- & item. attrs ,
228
+ & item. attrs . doc_strings ,
219
229
) ?;
220
230
221
231
cx. tcx . struct_span_lint_hir ( crate :: lint:: REDUNDANT_EXPLICIT_LINKS , hir_id, explicit_span, "redundant explicit link target" , |lint| {
0 commit comments