@@ -781,6 +781,14 @@ struct DocHeaders {
781781/// back in the various late lint pass methods if they need the final doc headers, like "Safety" or
782782/// "Panics" sections.
783783fn check_attrs ( cx : & LateContext < ' _ > , valid_idents : & FxHashSet < String > , attrs : & [ Attribute ] ) -> Option < DocHeaders > {
784+ // We don't want the parser to choke on intra doc links. Since we don't
785+ // actually care about rendering them, just pretend that all broken links
786+ // point to a fake address.
787+ #[ expect( clippy:: unnecessary_wraps) ] // we're following a type signature
788+ fn fake_broken_link_callback < ' a > ( _: BrokenLink < ' _ > ) -> Option < ( CowStr < ' a > , CowStr < ' a > ) > {
789+ Some ( ( "fake" . into ( ) , "fake" . into ( ) ) )
790+ }
791+
784792 if suspicious_doc_comments:: check ( cx, attrs) || is_doc_hidden ( attrs) {
785793 return None ;
786794 }
@@ -815,30 +823,12 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
815823 return Some ( DocHeaders :: default ( ) ) ;
816824 }
817825
818- // We don't want the parser to choke on intra doc links. Since we don't
819- // actually care about rendering them, just pretend that all broken links
820- // point to a fake address.
821- // NOTE: use this full cb version only for the check_doc function.
822- // Otherwise, using it as callback for more functions will cause,
823- // duplicated diagnostics for the broken link checker.
824- // Use the light cb version for the other cases.
825- #[ expect( clippy:: unnecessary_wraps) ] // we're following a type signature
826- let mut full_fake_broken_link_callback = |bl : BrokenLink < ' _ > | -> Option < ( CowStr < ' _ > , CowStr < ' _ > ) > {
827- broken_link:: check ( cx, & bl, & doc, & fragments) ;
828- Some ( ( "fake" . into ( ) , "fake" . into ( ) ) )
829- } ;
830-
831- #[ expect( clippy:: unnecessary_wraps) ] // we're following a type signature
832- fn light_fake_broken_link_callback < ' a > ( _: BrokenLink < ' _ > ) -> Option < ( CowStr < ' a > , CowStr < ' a > ) > {
833- Some ( ( "fake" . into ( ) , "fake" . into ( ) ) )
834- }
835-
836826 check_for_code_clusters (
837827 cx,
838828 pulldown_cmark:: Parser :: new_with_broken_link_callback (
839829 & doc,
840830 main_body_opts ( ) - Options :: ENABLE_SMART_PUNCTUATION ,
841- Some ( & mut light_fake_broken_link_callback ) ,
831+ Some ( & mut fake_broken_link_callback ) ,
842832 )
843833 . into_offset_iter ( ) ,
844834 & doc,
@@ -848,6 +838,13 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
848838 } ,
849839 ) ;
850840
841+ // NOTE: check_doc uses it own cb function,
842+ // to avoid causing duplicated diagnostics for the broken link checker.
843+ let mut full_fake_broken_link_callback = |bl : BrokenLink < ' _ > | -> Option < ( CowStr < ' _ > , CowStr < ' _ > ) > {
844+ broken_link:: check ( cx, & bl, & doc, & fragments) ;
845+ Some ( ( "fake" . into ( ) , "fake" . into ( ) ) )
846+ } ;
847+
851848 // disable smart punctuation to pick up ['link'] more easily
852849 let opts = main_body_opts ( ) - Options :: ENABLE_SMART_PUNCTUATION ;
853850 let parser =
0 commit comments