@@ -16,7 +16,7 @@ use rustc_ast::*;
16
16
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
17
17
use rustc_errors:: { Applicability , DiagnosticArgValue , DiagnosticId , IntoDiagnosticArg } ;
18
18
use rustc_hir:: def:: Namespace :: { self , * } ;
19
- use rustc_hir:: def:: { self , CtorKind , DefKind , LifetimeRes , PartialRes , PerNS } ;
19
+ use rustc_hir:: def:: { self , CtorKind , DefKind , LifetimeRes , NonMacroAttrKind , PartialRes , PerNS } ;
20
20
use rustc_hir:: def_id:: { DefId , LocalDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
21
21
use rustc_hir:: { BindingAnnotation , PrimTy , TraitCandidate } ;
22
22
use rustc_middle:: middle:: resolve_bound_vars:: Set1 ;
@@ -4275,12 +4275,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4275
4275
}
4276
4276
}
4277
4277
4278
- fn resolve_and_cache_rustdoc_path ( & mut self , path_str : & str , ns : Namespace ) -> bool {
4278
+ fn resolve_and_cache_rustdoc_path ( & mut self , path_str : & str , ns : Namespace ) -> Option < Res > {
4279
4279
// FIXME: This caching may be incorrect in case of multiple `macro_rules`
4280
4280
// items with the same name in the same module.
4281
4281
// Also hygiene is not considered.
4282
4282
let mut doc_link_resolutions = std:: mem:: take ( & mut self . r . doc_link_resolutions ) ;
4283
- let res = doc_link_resolutions
4283
+ let res = * doc_link_resolutions
4284
4284
. entry ( self . parent_scope . module . nearest_parent_mod ( ) . expect_local ( ) )
4285
4285
. or_default ( )
4286
4286
. entry ( ( Symbol :: intern ( path_str) , ns) )
@@ -4295,8 +4295,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4295
4295
return None ;
4296
4296
}
4297
4297
res
4298
- } )
4299
- . is_some ( ) ;
4298
+ } ) ;
4300
4299
self . r . doc_link_resolutions = doc_link_resolutions;
4301
4300
res
4302
4301
}
@@ -4331,8 +4330,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4331
4330
let mut any_resolved = false ;
4332
4331
let mut need_assoc = false ;
4333
4332
for ns in [ TypeNS , ValueNS , MacroNS ] {
4334
- if self . resolve_and_cache_rustdoc_path ( & path_str, ns) {
4335
- any_resolved = true ;
4333
+ if let Some ( res) = self . resolve_and_cache_rustdoc_path ( & path_str, ns) {
4334
+ // Rustdoc ignores tool attribute resolutions and attempts
4335
+ // to resolve their prefixes for diagnostics.
4336
+ any_resolved = !matches ! ( res, Res :: NonMacroAttr ( NonMacroAttrKind :: Tool ) ) ;
4336
4337
} else if ns != MacroNS {
4337
4338
need_assoc = true ;
4338
4339
}
0 commit comments