@@ -19,52 +19,52 @@ pub fn check(cx: &LateContext<'_>, bl: &PullDownBrokenLink<'_>, doc: &str, fragm
1919}
2020
2121fn warn_if_broken_link ( cx : & LateContext < ' _ > , bl : & PullDownBrokenLink < ' _ > , doc : & str , fragments : & [ DocFragment ] ) {
22- if let Some ( ( span, _) ) = source_span_for_markdown_range ( cx. tcx , doc, & bl. span , fragments) {
23- let mut len = 0 ;
22+ let mut len = 0 ;
2423
25- // grab raw link data
26- let ( _, raw_link) = doc. split_at ( bl. span . start ) ;
24+ // grab raw link data
25+ let ( _, raw_link) = doc. split_at ( bl. span . start ) ;
2726
28- // strip off link text part
29- let raw_link = match raw_link. split_once ( ']' ) {
30- None => return ,
31- Some ( ( prefix, suffix) ) => {
32- len += prefix. len ( ) + 1 ;
33- suffix
34- } ,
35- } ;
27+ // strip off link text part
28+ let raw_link = match raw_link. split_once ( ']' ) {
29+ None => return ,
30+ Some ( ( prefix, suffix) ) => {
31+ len += prefix. len ( ) + 1 ;
32+ suffix
33+ } ,
34+ } ;
3635
37- let raw_link = match raw_link. split_once ( '(' ) {
38- None => return ,
39- Some ( ( prefix, suffix) ) => {
40- if !prefix. is_empty ( ) {
41- // there is text between ']' and '(' chars, so it is not a valid link
42- return ;
43- }
44- len += prefix. len ( ) + 1 ;
45- suffix
46- } ,
47- } ;
48-
49- if raw_link. starts_with ( "(http" ) {
50- // reduce chances of false positive reports
51- // by limiting this checking only to http/https links.
52- return ;
53- }
54-
55- for c in raw_link. chars ( ) {
56- if c == ')' {
57- // it is a valid link
36+ let raw_link = match raw_link. split_once ( '(' ) {
37+ None => return ,
38+ Some ( ( prefix, suffix) ) => {
39+ if !prefix. is_empty ( ) {
40+ // there is text between ']' and '(' chars, so it is not a valid link
5841 return ;
5942 }
43+ len += prefix. len ( ) + 1 ;
44+ suffix
45+ } ,
46+ } ;
6047
61- if c == '\n' {
62- report_broken_link ( cx, span, len) ;
63- break ;
64- }
48+ if raw_link. starts_with ( "(http" ) {
49+ // reduce chances of false positive reports
50+ // by limiting this checking only to http/https links.
51+ return ;
52+ }
6553
66- len += 1 ;
54+ for c in raw_link. chars ( ) {
55+ if c == ')' {
56+ // it is a valid link
57+ return ;
6758 }
59+
60+ if c == '\n'
61+ && let Some ( ( span, _) ) = source_span_for_markdown_range ( cx. tcx , doc, & bl. span , fragments)
62+ {
63+ report_broken_link ( cx, span, len) ;
64+ break ;
65+ }
66+
67+ len += 1 ;
6868 }
6969}
7070
0 commit comments