@@ -4794,14 +4794,10 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
47944794 let res = self . r . resolve_rustdoc_path ( path. as_str ( ) , * ns, self . parent_scope ) ;
47954795 if let Some ( res) = res
47964796 && let Some ( def_id) = res. opt_def_id ( )
4797- && !def_id. is_local ( )
4798- && self . r . tcx . crate_types ( ) . contains ( & CrateType :: ProcMacro )
4799- && matches ! (
4800- self . r. tcx. sess. opts. resolve_doc_links,
4801- ResolveDocLinks :: ExportedMetadata
4802- )
4797+ && self . is_invalid_proc_macro_item_for_doc ( def_id)
48034798 {
4804- // Encoding foreign def ids in proc macro crate metadata will ICE.
4799+ // Encoding def ids in proc macro crate metadata will ICE,
4800+ // because it will only store proc macros for it.
48054801 return None ;
48064802 }
48074803 res
@@ -4810,6 +4806,17 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
48104806 res
48114807 }
48124808
4809+ fn is_invalid_proc_macro_item_for_doc ( & self , did : DefId ) -> bool {
4810+ if !matches ! ( self . r. tcx. sess. opts. resolve_doc_links, ResolveDocLinks :: ExportedMetadata )
4811+ || !self . r . tcx . crate_types ( ) . contains ( & CrateType :: ProcMacro )
4812+ {
4813+ return false ;
4814+ }
4815+ let Some ( local_did) = did. as_local ( ) else { return true } ;
4816+ let Some ( node_id) = self . r . def_id_to_node_id . get ( local_did) else { return true } ;
4817+ !self . r . proc_macros . contains ( node_id)
4818+ }
4819+
48134820 fn resolve_doc_links ( & mut self , attrs : & [ Attribute ] , maybe_exported : MaybeExported < ' _ > ) {
48144821 match self . r . tcx . sess . opts . resolve_doc_links {
48154822 ResolveDocLinks :: None => return ,
@@ -4872,14 +4879,9 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
48724879 . traits_in_scope ( None , & self . parent_scope , SyntaxContext :: root ( ) , None )
48734880 . into_iter ( )
48744881 . filter_map ( |tr| {
4875- if !tr. def_id . is_local ( )
4876- && self . r . tcx . crate_types ( ) . contains ( & CrateType :: ProcMacro )
4877- && matches ! (
4878- self . r. tcx. sess. opts. resolve_doc_links,
4879- ResolveDocLinks :: ExportedMetadata
4880- )
4881- {
4882- // Encoding foreign def ids in proc macro crate metadata will ICE.
4882+ if self . is_invalid_proc_macro_item_for_doc ( tr. def_id ) {
4883+ // Encoding def ids in proc macro crate metadata will ICE.
4884+ // because it will only store proc macros for it.
48834885 return None ;
48844886 }
48854887 Some ( tr. def_id )
0 commit comments