@@ -17,7 +17,7 @@ use rustc_ast::*;
17
17
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
18
18
use rustc_errors:: { Applicability , DiagnosticArgValue , DiagnosticId , IntoDiagnosticArg } ;
19
19
use 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 } ;
21
21
use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
22
22
use rustc_hir:: { BindingAnnotation , PrimTy , TraitCandidate } ;
23
23
use rustc_middle:: middle:: resolve_bound_vars:: Set1 ;
@@ -4287,12 +4287,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4287
4287
}
4288
4288
}
4289
4289
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 > {
4291
4291
// FIXME: This caching may be incorrect in case of multiple `macro_rules`
4292
4292
// items with the same name in the same module.
4293
4293
// Also hygiene is not considered.
4294
4294
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
4296
4296
. entry ( self . parent_scope . module . nearest_parent_mod ( ) . expect_local ( ) )
4297
4297
. or_default ( )
4298
4298
. entry ( ( Symbol :: intern ( path_str) , ns) )
@@ -4307,8 +4307,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4307
4307
return None ;
4308
4308
}
4309
4309
res
4310
- } )
4311
- . is_some ( ) ;
4310
+ } ) ;
4312
4311
self . r . doc_link_resolutions = doc_link_resolutions;
4313
4312
res
4314
4313
}
@@ -4343,8 +4342,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4343
4342
let mut any_resolved = false ;
4344
4343
let mut need_assoc = false ;
4345
4344
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 ) ) ;
4348
4349
} else if ns != MacroNS {
4349
4350
need_assoc = true ;
4350
4351
}
0 commit comments