@@ -124,7 +124,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
124
124
}
125
125
126
126
/// Resolves a string as a macro.
127
- fn macro_resolve ( & self , path_str : & str , parent_id : Option < hir :: HirId > ) -> Option < Res > {
127
+ fn macro_resolve ( & self , path_str : & str , parent_id : Option < DefId > ) -> Option < Res > {
128
128
let cx = self . cx ;
129
129
let path = ast:: Path :: from_ident ( Ident :: from_str ( path_str) ) ;
130
130
cx. enter_resolver ( |resolver| {
@@ -142,8 +142,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
142
142
if let Some ( res) = resolver. all_macros ( ) . get ( & Symbol :: intern ( path_str) ) {
143
143
return Some ( res. map_id ( |_| panic ! ( "unexpected id" ) ) ) ;
144
144
}
145
- if let Some ( module_id) = parent_id. or ( self . mod_ids . last ( ) . cloned ( ) ) {
146
- let module_id = cx. tcx . hir ( ) . local_def_id ( module_id) ;
145
+ if let Some ( module_id) = parent_id {
147
146
if let Ok ( ( _, res) ) =
148
147
resolver. resolve_str_path_error ( DUMMY_SP , path_str, MacroNS , module_id)
149
148
{
@@ -167,17 +166,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
167
166
disambiguator : Option < & str > ,
168
167
ns : Namespace ,
169
168
current_item : & Option < String > ,
170
- mut parent_id : Option < DefId > ,
169
+ parent_id : Option < DefId > ,
171
170
extra_fragment : & Option < String > ,
172
171
item_opt : Option < & Item > ,
173
172
) -> Result < ( Res , Option < String > ) , ErrorKind > {
174
173
let cx = self . cx ;
175
174
176
175
// In case we're in a module, try to resolve the relative path.
177
- if parent_id. is_none ( ) {
178
- let id = self . mod_ids . last ( ) . cloned ( ) ;
179
- parent_id = id. map ( |id| cx. tcx . hir ( ) . local_def_id ( id) . to_def_id ( ) ) ;
180
- }
181
176
if let Some ( module_id) = parent_id {
182
177
let result = cx. enter_resolver ( |resolver| {
183
178
resolver. resolve_str_path_error ( DUMMY_SP , & path_str, ns, module_id)
@@ -659,8 +654,11 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
659
654
// we've already pushed this node onto the resolution stack but
660
655
// for outer comments we explicitly try and resolve against the
661
656
// parent_node first.
662
- let base_node =
663
- if item. is_mod ( ) && item. attrs . inner_docs { None } else { parent_node } ;
657
+ let base_node = if item. is_mod ( ) && item. attrs . inner_docs {
658
+ self . mod_ids . last ( ) . map ( |& id| self . cx . tcx . hir ( ) . local_def_id ( id) . to_def_id ( ) )
659
+ } else {
660
+ parent_node
661
+ } ;
664
662
665
663
// replace `Self` with suitable item's parent name
666
664
if path_str. starts_with ( "Self::" ) {
0 commit comments