@@ -6,10 +6,11 @@ use clippy_utils::ty::is_type_diagnostic_item;
66use clippy_utils:: visitors:: Visitable ;
77use clippy_utils:: { in_constant, is_entrypoint_fn, is_trait_impl_item, method_chain_args} ;
88use pulldown_cmark:: Event :: {
9- Code , End , FootnoteReference , HardBreak , Html , Rule , SoftBreak , Start , TaskListMarker , Text ,
9+ Code , DisplayMath , End , FootnoteReference , HardBreak , Html , InlineHtml , InlineMath , Rule , SoftBreak , Start ,
10+ TaskListMarker , Text ,
1011} ;
1112use pulldown_cmark:: Tag :: { BlockQuote , CodeBlock , FootnoteDefinition , Heading , Item , Link , Paragraph } ;
12- use pulldown_cmark:: { BrokenLink , CodeBlockKind , CowStr , Options } ;
13+ use pulldown_cmark:: { BrokenLink , CodeBlockKind , CowStr , Options , TagEnd } ;
1314use rustc_ast:: ast:: Attribute ;
1415use rustc_data_structures:: fx:: FxHashSet ;
1516use rustc_hir:: intravisit:: { self , Visitor } ;
@@ -659,7 +660,7 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
659660
660661 while let Some ( ( event, range) ) = events. next ( ) {
661662 match event {
662- Html ( tag) => {
663+ Html ( tag) | InlineHtml ( tag ) => {
663664 if tag. starts_with ( "<code" ) {
664665 code_level += 1 ;
665666 } else if tag. starts_with ( "</code" ) {
@@ -670,11 +671,11 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
670671 blockquote_level -= 1 ;
671672 }
672673 } ,
673- Start ( BlockQuote ) => {
674+ Start ( BlockQuote ( _ ) ) => {
674675 blockquote_level += 1 ;
675676 containers. push ( Container :: Blockquote ) ;
676677 } ,
677- End ( BlockQuote ) => {
678+ End ( TagEnd :: BlockQuote ) => {
678679 blockquote_level -= 1 ;
679680 containers. pop ( ) ;
680681 } ,
@@ -699,15 +700,15 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
699700 }
700701 }
701702 } ,
702- End ( CodeBlock ( _ ) ) => {
703+ End ( TagEnd :: CodeBlock ) => {
703704 in_code = false ;
704705 is_rust = false ;
705706 ignore = false ;
706707 } ,
707- Start ( Link ( _ , url , _ ) ) => in_link = Some ( url ) ,
708- End ( Link ( .. ) ) => in_link = None ,
709- Start ( Heading ( _ , _ , _ ) | Paragraph | Item ) => {
710- if let Start ( Heading ( _ , _ , _ ) ) = event {
708+ Start ( Link { dest_url , .. } ) => in_link = Some ( dest_url ) ,
709+ End ( TagEnd :: Link ) => in_link = None ,
710+ Start ( Heading { .. } | Paragraph | Item ) => {
711+ if let Start ( Heading { .. } ) = event {
711712 in_heading = true ;
712713 }
713714 if let Start ( Item ) = event {
@@ -720,11 +721,11 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
720721 ticks_unbalanced = false ;
721722 paragraph_range = range;
722723 } ,
723- End ( Heading ( _, _ , _ ) | Paragraph | Item ) => {
724- if let End ( Heading ( _ , _ , _) ) = event {
724+ End ( TagEnd :: Heading ( _) | TagEnd :: Paragraph | TagEnd :: Item ) => {
725+ if let End ( TagEnd :: Heading ( _) ) = event {
725726 in_heading = false ;
726727 }
727- if let End ( Item ) = event {
728+ if let End ( TagEnd :: Item ) = event {
728729 containers. pop ( ) ;
729730 }
730731 if ticks_unbalanced && let Some ( span) = fragments. span ( cx, paragraph_range. clone ( ) ) {
@@ -746,8 +747,9 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
746747 text_to_check = Vec :: new ( ) ;
747748 } ,
748749 Start ( FootnoteDefinition ( ..) ) => in_footnote_definition = true ,
749- End ( FootnoteDefinition ( ..) ) => in_footnote_definition = false ,
750- Start ( _tag) | End ( _tag) => ( ) , // We don't care about other tags
750+ End ( TagEnd :: FootnoteDefinition ) => in_footnote_definition = false ,
751+ Start ( _) | End ( _) // We don't care about other tags
752+ | TaskListMarker ( _) | Code ( _) | Rule | InlineMath ( ..) | DisplayMath ( ..) => ( ) ,
751753 SoftBreak | HardBreak => {
752754 if !containers. is_empty ( )
753755 && let Some ( ( next_event, next_range) ) = events. peek ( )
@@ -766,7 +768,6 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
766768 ) ;
767769 }
768770 } ,
769- TaskListMarker ( _) | Code ( _) | Rule => ( ) ,
770771 FootnoteReference ( text) | Text ( text) => {
771772 paragraph_range. end = range. end ;
772773 let range_ = range. clone ( ) ;
0 commit comments