@@ -6,6 +6,11 @@ use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
6
6
use clippy_utils:: { is_entrypoint_fn, method_chain_args, return_ty} ;
7
7
use if_chain:: if_chain;
8
8
use itertools:: Itertools ;
9
+ use pulldown_cmark:: Event :: {
10
+ Code , End , FootnoteReference , HardBreak , Html , Rule , SoftBreak , Start , TaskListMarker , Text ,
11
+ } ;
12
+ use pulldown_cmark:: Tag :: { CodeBlock , Heading , Item , Link , Paragraph } ;
13
+ use pulldown_cmark:: { BrokenLink , CodeBlockKind , CowStr , Options } ;
9
14
use rustc_ast:: ast:: { Async , AttrKind , Attribute , Fn , FnRetTy , ItemKind } ;
10
15
use rustc_ast:: token:: CommentKind ;
11
16
use rustc_data_structures:: fx:: FxHashSet ;
@@ -497,7 +502,6 @@ struct DocHeaders {
497
502
}
498
503
499
504
fn check_attrs ( cx : & LateContext < ' _ > , valid_idents : & FxHashSet < String > , attrs : & [ Attribute ] ) -> Option < DocHeaders > {
500
- use pulldown_cmark:: { BrokenLink , CowStr , Options } ;
501
505
/// We don't want the parser to choke on intra doc links. Since we don't
502
506
/// actually care about rendering them, just pretend that all broken links are
503
507
/// point to a fake address.
@@ -538,8 +542,6 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
538
542
pulldown_cmark:: Parser :: new_with_broken_link_callback ( & doc, Options :: empty ( ) , Some ( & mut cb) ) . into_offset_iter ( ) ;
539
543
// Iterate over all `Events` and combine consecutive events into one
540
544
let events = parser. coalesce ( |previous, current| {
541
- use pulldown_cmark:: Event :: Text ;
542
-
543
545
let previous_range = previous. 1 ;
544
546
let current_range = current. 1 ;
545
547
@@ -564,12 +566,6 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
564
566
spans : & [ ( usize , Span ) ] ,
565
567
) -> DocHeaders {
566
568
// true if a safety header was found
567
- use pulldown_cmark:: Event :: {
568
- Code , End , FootnoteReference , HardBreak , Html , Rule , SoftBreak , Start , TaskListMarker , Text ,
569
- } ;
570
- use pulldown_cmark:: Tag :: { CodeBlock , Heading , Item , Link , Paragraph } ;
571
- use pulldown_cmark:: { CodeBlockKind , CowStr } ;
572
-
573
569
let mut headers = DocHeaders :: default ( ) ;
574
570
let mut in_code = false ;
575
571
let mut in_link = None ;
@@ -660,6 +656,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
660
656
check_link_quotes ( cx, in_link. is_some ( ) , trimmed_text, span, & range, begin, text. len ( ) ) ;
661
657
// Adjust for the beginning of the current `Event`
662
658
let span = span. with_lo ( span. lo ( ) + BytePos :: from_usize ( range. start - begin) ) ;
659
+ if let Some ( link) = in_link. as_ref ( )
660
+ && let Ok ( url) = Url :: parse ( link)
661
+ && ( url. scheme ( ) == "https" || url. scheme ( ) == "http" ) {
662
+ // Don't check the text associated with external URLs
663
+ continue ;
664
+ }
663
665
text_to_check. push ( ( text, span) ) ;
664
666
}
665
667
} ,
0 commit comments