@@ -6,6 +6,11 @@ use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
66use clippy_utils:: { is_entrypoint_fn, method_chain_args, return_ty} ;
77use if_chain:: if_chain;
88use 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 } ;
914use rustc_ast:: ast:: { Async , AttrKind , Attribute , Fn , FnRetTy , ItemKind } ;
1015use rustc_ast:: token:: CommentKind ;
1116use rustc_data_structures:: fx:: FxHashSet ;
@@ -497,7 +502,6 @@ struct DocHeaders {
497502}
498503
499504fn check_attrs ( cx : & LateContext < ' _ > , valid_idents : & FxHashSet < String > , attrs : & [ Attribute ] ) -> Option < DocHeaders > {
500- use pulldown_cmark:: { BrokenLink , CowStr , Options } ;
501505 /// We don't want the parser to choke on intra doc links. Since we don't
502506 /// actually care about rendering them, just pretend that all broken links are
503507 /// point to a fake address.
@@ -538,8 +542,6 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
538542 pulldown_cmark:: Parser :: new_with_broken_link_callback ( & doc, Options :: empty ( ) , Some ( & mut cb) ) . into_offset_iter ( ) ;
539543 // Iterate over all `Events` and combine consecutive events into one
540544 let events = parser. coalesce ( |previous, current| {
541- use pulldown_cmark:: Event :: Text ;
542-
543545 let previous_range = previous. 1 ;
544546 let current_range = current. 1 ;
545547
@@ -564,12 +566,6 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
564566 spans : & [ ( usize , Span ) ] ,
565567) -> DocHeaders {
566568 // 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-
573569 let mut headers = DocHeaders :: default ( ) ;
574570 let mut in_code = false ;
575571 let mut in_link = None ;
@@ -660,6 +656,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
660656 check_link_quotes ( cx, in_link. is_some ( ) , trimmed_text, span, & range, begin, text. len ( ) ) ;
661657 // Adjust for the beginning of the current `Event`
662658 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+ }
663665 text_to_check. push ( ( text, span) ) ;
664666 }
665667 } ,
0 commit comments