@@ -18,19 +18,23 @@ use crate::html::markdown::main_body_opts;
18
18
19
19
pub ( super ) fn visit_item ( cx : & DocContext < ' _ > , item : & Item , hir_id : HirId , dox : & str ) {
20
20
let report_diag = |cx : & DocContext < ' _ > , msg : & ' static str , range : Range < usize > | {
21
- let sp = source_span_for_markdown_range ( cx. tcx , dox, & range, & item. attrs . doc_strings )
22
- . unwrap_or_else ( || item. attr_span ( cx. tcx ) ) ;
21
+ let maybe_sp = source_span_for_markdown_range ( cx. tcx , dox, & range, & item. attrs . doc_strings ) ;
22
+ let sp = maybe_sp . unwrap_or_else ( || item. attr_span ( cx. tcx ) ) ;
23
23
cx. tcx . node_span_lint ( crate :: lint:: BARE_URLS , hir_id, sp, |lint| {
24
24
lint. primary_message ( msg)
25
- . note ( "bare URLs are not automatically turned into clickable links" )
26
- . multipart_suggestion (
25
+ . note ( "bare URLs are not automatically turned into clickable links" ) ;
26
+ // the fallback of using the item span is suitible for
27
+ // highlighting where the error is, but not for placing the < and >
28
+ if let Some ( sp) = maybe_sp {
29
+ lint. multipart_suggestion (
27
30
"use an automatic link instead" ,
28
31
vec ! [
29
32
( sp. shrink_to_lo( ) , "<" . to_string( ) ) ,
30
33
( sp. shrink_to_hi( ) , ">" . to_string( ) ) ,
31
34
] ,
32
35
Applicability :: MachineApplicable ,
33
36
) ;
37
+ }
34
38
} ) ;
35
39
} ;
36
40
0 commit comments