@@ -17,7 +17,7 @@ use rustc_ast::*;
1717use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
1818use rustc_errors:: { Applicability , DiagnosticArgValue , DiagnosticId , IntoDiagnosticArg } ;
1919use rustc_hir:: def:: Namespace :: { self , * } ;
20- use rustc_hir:: def:: { self , CtorKind , DefKind , LifetimeRes , PartialRes , PerNS } ;
20+ use rustc_hir:: def:: { self , CtorKind , DefKind , LifetimeRes , NonMacroAttrKind , PartialRes , PerNS } ;
2121use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
2222use rustc_hir:: { BindingAnnotation , PrimTy , TraitCandidate } ;
2323use rustc_middle:: middle:: resolve_bound_vars:: Set1 ;
@@ -4287,12 +4287,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
42874287 }
42884288 }
42894289
4290- fn resolve_and_cache_rustdoc_path ( & mut self , path_str : & str , ns : Namespace ) -> bool {
4290+ fn resolve_and_cache_rustdoc_path ( & mut self , path_str : & str , ns : Namespace ) -> Option < Res > {
42914291 // FIXME: This caching may be incorrect in case of multiple `macro_rules`
42924292 // items with the same name in the same module.
42934293 // Also hygiene is not considered.
42944294 let mut doc_link_resolutions = std:: mem:: take ( & mut self . r . doc_link_resolutions ) ;
4295- let res = doc_link_resolutions
4295+ let res = * doc_link_resolutions
42964296 . entry ( self . parent_scope . module . nearest_parent_mod ( ) . expect_local ( ) )
42974297 . or_default ( )
42984298 . entry ( ( Symbol :: intern ( path_str) , ns) )
@@ -4307,8 +4307,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
43074307 return None ;
43084308 }
43094309 res
4310- } )
4311- . is_some ( ) ;
4310+ } ) ;
43124311 self . r . doc_link_resolutions = doc_link_resolutions;
43134312 res
43144313 }
@@ -4343,8 +4342,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
43434342 let mut any_resolved = false ;
43444343 let mut need_assoc = false ;
43454344 for ns in [ TypeNS , ValueNS , MacroNS ] {
4346- if self . resolve_and_cache_rustdoc_path ( & path_str, ns) {
4347- any_resolved = true ;
4345+ if let Some ( res) = self . resolve_and_cache_rustdoc_path ( & path_str, ns) {
4346+ // Rustdoc ignores tool attribute resolutions and attempts
4347+ // to resolve their prefixes for diagnostics.
4348+ any_resolved = !matches ! ( res, Res :: NonMacroAttr ( NonMacroAttrKind :: Tool ) ) ;
43484349 } else if ns != MacroNS {
43494350 need_assoc = true ;
43504351 }
0 commit comments