@@ -208,17 +208,12 @@ impl<'hir> Map<'hir> {
208208 self . definitions . def_key ( def_id. index )
209209 }
210210
211- pub fn def_path_from_id ( & self , id : NodeId ) -> Option < DefPath > {
212- self . opt_local_def_id ( id) . map ( |def_id| {
211+ pub fn def_path_from_hir_id ( & self , id : HirId ) -> Option < DefPath > {
212+ self . opt_local_def_id_from_hir_id ( id) . map ( |def_id| {
213213 self . def_path ( def_id)
214214 } )
215215 }
216216
217- // FIXME(@ljedrz): replace the NodeId variant
218- pub fn def_path_from_hir_id ( & self , id : HirId ) -> DefPath {
219- self . def_path ( self . local_def_id_from_hir_id ( id) )
220- }
221-
222217 pub fn def_path ( & self , def_id : DefId ) -> DefPath {
223218 assert ! ( def_id. is_local( ) ) ;
224219 self . definitions . def_path ( def_id. index )
@@ -1075,7 +1070,7 @@ impl<'hir> Map<'hir> {
10751070 }
10761071
10771072 pub fn node_to_string ( & self , id : NodeId ) -> String {
1078- node_id_to_string ( self , id , true )
1073+ hir_id_to_string ( self , self . node_to_hir_id ( id ) , true )
10791074 }
10801075
10811076 // FIXME(@ljedrz): replace the NodeId variant
@@ -1084,7 +1079,7 @@ impl<'hir> Map<'hir> {
10841079 }
10851080
10861081 pub fn node_to_user_string ( & self , id : NodeId ) -> String {
1087- node_id_to_string ( self , id , false )
1082+ hir_id_to_string ( self , self . node_to_hir_id ( id ) , false )
10881083 }
10891084
10901085 // FIXME(@ljedrz): replace the NodeId variant
@@ -1303,18 +1298,18 @@ impl<'a> print::State<'a> {
13031298 }
13041299}
13051300
1306- fn node_id_to_string ( map : & Map < ' _ > , id : NodeId , include_id : bool ) -> String {
1307- let id_str = format ! ( " (id ={})" , id) ;
1301+ fn hir_id_to_string ( map : & Map < ' _ > , id : HirId , include_id : bool ) -> String {
1302+ let id_str = format ! ( " (hir_id ={})" , id) ;
13081303 let id_str = if include_id { & id_str[ ..] } else { "" } ;
13091304
13101305 let path_str = || {
13111306 // This functionality is used for debugging, try to use TyCtxt to get
13121307 // the user-friendly path, otherwise fall back to stringifying DefPath.
13131308 crate :: ty:: tls:: with_opt ( |tcx| {
13141309 if let Some ( tcx) = tcx {
1315- let def_id = map. local_def_id ( id) ;
1310+ let def_id = map. local_def_id_from_hir_id ( id) ;
13161311 tcx. def_path_str ( def_id)
1317- } else if let Some ( path) = map. def_path_from_id ( id) {
1312+ } else if let Some ( path) = map. def_path_from_hir_id ( id) {
13181313 path. data . into_iter ( ) . map ( |elem| {
13191314 elem. data . to_string ( )
13201315 } ) . collect :: < Vec < _ > > ( ) . join ( "::" )
@@ -1324,7 +1319,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
13241319 } )
13251320 } ;
13261321
1327- match map. find ( id) {
1322+ match map. find_by_hir_id ( id) {
13281323 Some ( Node :: Item ( item) ) => {
13291324 let item_str = match item. node {
13301325 ItemKind :: ExternCrate ( ..) => "extern crate" ,
@@ -1385,40 +1380,40 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
13851380 path_str( ) , id_str)
13861381 }
13871382 Some ( Node :: AnonConst ( _) ) => {
1388- format ! ( "const {}{}" , map. node_to_pretty_string ( id) , id_str)
1383+ format ! ( "const {}{}" , map. hir_to_pretty_string ( id) , id_str)
13891384 }
13901385 Some ( Node :: Expr ( _) ) => {
1391- format ! ( "expr {}{}" , map. node_to_pretty_string ( id) , id_str)
1386+ format ! ( "expr {}{}" , map. hir_to_pretty_string ( id) , id_str)
13921387 }
13931388 Some ( Node :: Stmt ( _) ) => {
1394- format ! ( "stmt {}{}" , map. node_to_pretty_string ( id) , id_str)
1389+ format ! ( "stmt {}{}" , map. hir_to_pretty_string ( id) , id_str)
13951390 }
13961391 Some ( Node :: PathSegment ( _) ) => {
1397- format ! ( "path segment {}{}" , map. node_to_pretty_string ( id) , id_str)
1392+ format ! ( "path segment {}{}" , map. hir_to_pretty_string ( id) , id_str)
13981393 }
13991394 Some ( Node :: Ty ( _) ) => {
1400- format ! ( "type {}{}" , map. node_to_pretty_string ( id) , id_str)
1395+ format ! ( "type {}{}" , map. hir_to_pretty_string ( id) , id_str)
14011396 }
14021397 Some ( Node :: TraitRef ( _) ) => {
1403- format ! ( "trait_ref {}{}" , map. node_to_pretty_string ( id) , id_str)
1398+ format ! ( "trait_ref {}{}" , map. hir_to_pretty_string ( id) , id_str)
14041399 }
14051400 Some ( Node :: Binding ( _) ) => {
1406- format ! ( "local {}{}" , map. node_to_pretty_string ( id) , id_str)
1401+ format ! ( "local {}{}" , map. hir_to_pretty_string ( id) , id_str)
14071402 }
14081403 Some ( Node :: Pat ( _) ) => {
1409- format ! ( "pat {}{}" , map. node_to_pretty_string ( id) , id_str)
1404+ format ! ( "pat {}{}" , map. hir_to_pretty_string ( id) , id_str)
14101405 }
14111406 Some ( Node :: Block ( _) ) => {
1412- format ! ( "block {}{}" , map. node_to_pretty_string ( id) , id_str)
1407+ format ! ( "block {}{}" , map. hir_to_pretty_string ( id) , id_str)
14131408 }
14141409 Some ( Node :: Local ( _) ) => {
1415- format ! ( "local {}{}" , map. node_to_pretty_string ( id) , id_str)
1410+ format ! ( "local {}{}" , map. hir_to_pretty_string ( id) , id_str)
14161411 }
14171412 Some ( Node :: Ctor ( ..) ) => {
14181413 format ! ( "ctor {}{}" , path_str( ) , id_str)
14191414 }
14201415 Some ( Node :: Lifetime ( _) ) => {
1421- format ! ( "lifetime {}{}" , map. node_to_pretty_string ( id) , id_str)
1416+ format ! ( "lifetime {}{}" , map. hir_to_pretty_string ( id) , id_str)
14221417 }
14231418 Some ( Node :: GenericParam ( ref param) ) => {
14241419 format ! ( "generic_param {:?}{}" , param, id_str)
@@ -1434,12 +1429,6 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
14341429 }
14351430}
14361431
1437- // FIXME(@ljedrz): replace the NodeId variant
1438- fn hir_id_to_string ( map : & Map < ' _ > , id : HirId , include_id : bool ) -> String {
1439- let node_id = map. hir_to_node_id ( id) ;
1440- node_id_to_string ( map, node_id, include_id)
1441- }
1442-
14431432pub fn def_kind ( tcx : TyCtxt < ' _ , ' _ , ' _ > , def_id : DefId ) -> Option < DefKind > {
14441433 if let Some ( node_id) = tcx. hir ( ) . as_local_node_id ( def_id) {
14451434 tcx. hir ( ) . def_kind ( node_id)
0 commit comments