@@ -124,7 +124,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
124124 }
125125
126126 /// 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 > {
128128 let cx = self . cx ;
129129 let path = ast:: Path :: from_ident ( Ident :: from_str ( path_str) ) ;
130130 cx. enter_resolver ( |resolver| {
@@ -142,8 +142,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
142142 if let Some ( res) = resolver. all_macros ( ) . get ( & Symbol :: intern ( path_str) ) {
143143 return Some ( res. map_id ( |_| panic ! ( "unexpected id" ) ) ) ;
144144 }
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 {
147146 if let Ok ( ( _, res) ) =
148147 resolver. resolve_str_path_error ( DUMMY_SP , path_str, MacroNS , module_id)
149148 {
@@ -167,17 +166,13 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
167166 disambiguator : Option < & str > ,
168167 ns : Namespace ,
169168 current_item : & Option < String > ,
170- mut parent_id : Option < DefId > ,
169+ parent_id : Option < DefId > ,
171170 extra_fragment : & Option < String > ,
172171 item_opt : Option < & Item > ,
173172 ) -> Result < ( Res , Option < String > ) , ErrorKind > {
174173 let cx = self . cx ;
175174
176175 // 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- }
181176 if let Some ( module_id) = parent_id {
182177 let result = cx. enter_resolver ( |resolver| {
183178 resolver. resolve_str_path_error ( DUMMY_SP , & path_str, ns, module_id)
@@ -659,8 +654,11 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
659654 // we've already pushed this node onto the resolution stack but
660655 // for outer comments we explicitly try and resolve against the
661656 // 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+ } ;
664662
665663 // replace `Self` with suitable item's parent name
666664 if path_str. starts_with ( "Self::" ) {
0 commit comments