@@ -434,18 +434,22 @@ impl Definitions {
434
434
DefPath :: make ( LOCAL_CRATE , index, |p| self . def_key ( p) )
435
435
}
436
436
437
+ #[ inline]
437
438
pub fn opt_def_index ( & self , node : ast:: NodeId ) -> Option < DefIndex > {
438
439
self . node_to_def_index . get ( & node) . cloned ( )
439
440
}
440
441
442
+ #[ inline]
441
443
pub fn opt_local_def_id ( & self , node : ast:: NodeId ) -> Option < DefId > {
442
444
self . opt_def_index ( node) . map ( DefId :: local)
443
445
}
444
446
447
+ #[ inline]
445
448
pub fn local_def_id ( & self , node : ast:: NodeId ) -> DefId {
446
449
self . opt_local_def_id ( node) . unwrap ( )
447
450
}
448
451
452
+ #[ inline]
449
453
pub fn as_local_node_id ( & self , def_id : DefId ) -> Option < ast:: NodeId > {
450
454
if def_id. krate == LOCAL_CRATE {
451
455
let space_index = def_id. index . address_space ( ) . index ( ) ;
@@ -461,6 +465,7 @@ impl Definitions {
461
465
}
462
466
}
463
467
468
+ #[ inline]
464
469
pub fn node_to_hir_id ( & self , node_id : ast:: NodeId ) -> hir:: HirId {
465
470
self . node_to_hir_id [ node_id]
466
471
}
@@ -473,6 +478,14 @@ impl Definitions {
473
478
. unwrap ( )
474
479
}
475
480
481
+ #[ inline]
482
+ pub fn def_index_to_hir_id ( & self , def_index : DefIndex ) -> hir:: HirId {
483
+ let space_index = def_index. address_space ( ) . index ( ) ;
484
+ let array_index = def_index. as_array_index ( ) ;
485
+ let node_id = self . def_index_to_node [ space_index] [ array_index] ;
486
+ self . node_to_hir_id [ node_id]
487
+ }
488
+
476
489
/// Add a definition with a parent definition.
477
490
pub fn create_root_def ( & mut self ,
478
491
crate_name : & str ,
0 commit comments