@@ -38,7 +38,7 @@ pub fn collect_intra_doc_links(krate: Crate, cx: &DocContext<'_>) -> Crate {
38
38
39
39
struct LinkCollector < ' a , ' tcx > {
40
40
cx : & ' a DocContext < ' tcx > ,
41
- mod_ids : Vec < ast :: NodeId > ,
41
+ mod_ids : Vec < hir :: HirId > ,
42
42
}
43
43
44
44
impl < ' a , ' tcx > LinkCollector < ' a , ' tcx > {
@@ -55,7 +55,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
55
55
path_str : & str ,
56
56
ns : Namespace ,
57
57
current_item : & Option < String > ,
58
- parent_id : Option < ast :: NodeId > )
58
+ parent_id : Option < hir :: HirId > )
59
59
-> Result < ( Def , Option < String > ) , ( ) >
60
60
{
61
61
let cx = self . cx ;
@@ -64,8 +64,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
64
64
// path.
65
65
if let Some ( id) = parent_id. or ( self . mod_ids . last ( ) . cloned ( ) ) {
66
66
// FIXME: `with_scope` requires the `NodeId` of a module.
67
+ let node_id = cx. tcx . hir ( ) . hir_to_node_id ( id) ;
67
68
let result = cx. enter_resolver ( |resolver| {
68
- resolver. with_scope ( id , |resolver| {
69
+ resolver. with_scope ( node_id , |resolver| {
69
70
resolver. resolve_str_path_error ( DUMMY_SP , & path_str, ns == ValueNS )
70
71
} )
71
72
} ) ;
@@ -127,7 +128,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
127
128
}
128
129
129
130
// FIXME: `with_scope` requires the `NodeId` of a module.
130
- let ty = cx. enter_resolver ( |resolver| resolver. with_scope ( id, |resolver| {
131
+ let node_id = cx. tcx . hir ( ) . hir_to_node_id ( id) ;
132
+ let ty = cx. enter_resolver ( |resolver| resolver. with_scope ( node_id, |resolver| {
131
133
resolver. resolve_str_path_error ( DUMMY_SP , & path, false )
132
134
} ) ) ?;
133
135
match ty. def {
@@ -215,11 +217,11 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
215
217
} ;
216
218
217
219
// FIXME: get the resolver to work with non-local resolve scopes.
218
- let parent_node = self . cx . as_local_node_id ( item. def_id ) . and_then ( |node_id | {
220
+ let parent_node = self . cx . as_local_hir_id ( item. def_id ) . and_then ( |hir_id | {
219
221
// FIXME: this fails hard for impls in non-module scope, but is necessary for the
220
222
// current `resolve()` implementation.
221
- match self . cx . tcx . hir ( ) . get_module_parent_node ( node_id ) {
222
- id if id != node_id => Some ( id) ,
223
+ match self . cx . tcx . hir ( ) . get_module_parent_node ( hir_id ) {
224
+ id if id != hir_id => Some ( id) ,
223
225
_ => None ,
224
226
}
225
227
} ) ;
@@ -238,9 +240,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
238
240
}
239
241
} else {
240
242
match parent_node. or ( self . mod_ids . last ( ) . cloned ( ) ) {
241
- Some ( parent) if parent != ast :: CRATE_NODE_ID => {
243
+ Some ( parent) if parent != hir :: CRATE_HIR_ID => {
242
244
// FIXME: can we pull the parent module's name from elsewhere?
243
- Some ( self . cx . tcx . hir ( ) . name ( parent) . to_string ( ) )
245
+ Some ( self . cx . tcx . hir ( ) . name_by_hir_id ( parent) . to_string ( ) )
244
246
}
245
247
_ => None ,
246
248
}
@@ -257,7 +259,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
257
259
} ;
258
260
259
261
if item. is_mod ( ) && item. attrs . inner_docs {
260
- self . mod_ids . push ( self . cx . tcx . hir ( ) . hir_to_node_id ( item_hir_id. unwrap ( ) ) ) ;
262
+ self . mod_ids . push ( item_hir_id. unwrap ( ) ) ;
261
263
}
262
264
263
265
let cx = self . cx ;
@@ -391,7 +393,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
391
393
}
392
394
393
395
if item. is_mod ( ) && !item. attrs . inner_docs {
394
- self . mod_ids . push ( self . cx . tcx . hir ( ) . hir_to_node_id ( item_hir_id. unwrap ( ) ) ) ;
396
+ self . mod_ids . push ( item_hir_id. unwrap ( ) ) ;
395
397
}
396
398
397
399
if item. is_mod ( ) {
0 commit comments