@@ -525,17 +525,14 @@ impl<'tcx> TypeckTables<'tcx> {
525525 }
526526 }
527527
528- pub fn node_id_to_type ( & self , id : hir:: HirId ) -> Ty < ' tcx > {
529- self . node_id_to_type_opt ( id) . unwrap_or_else ( ||
530- bug ! ( "node_id_to_type: no type for node `{}`" ,
531- tls:: with( |tcx| {
532- let id = tcx. hir( ) . hir_to_node_id( id) ;
533- tcx. hir( ) . node_to_string( id)
534- } ) )
528+ pub fn node_type ( & self , id : hir:: HirId ) -> Ty < ' tcx > {
529+ self . node_type_opt ( id) . unwrap_or_else ( ||
530+ bug ! ( "node_type: no type for node `{}`" ,
531+ tls:: with( |tcx| tcx. hir( ) . hir_to_string( id) ) )
535532 )
536533 }
537534
538- pub fn node_id_to_type_opt ( & self , id : hir:: HirId ) -> Option < Ty < ' tcx > > {
535+ pub fn node_type_opt ( & self , id : hir:: HirId ) -> Option < Ty < ' tcx > > {
539536 validate_hir_id_for_typeck_tables ( self . local_id_root , id, false ) ;
540537 self . node_types . get ( & id. local_id ) . cloned ( )
541538 }
@@ -560,11 +557,11 @@ impl<'tcx> TypeckTables<'tcx> {
560557 // Returns the type of a pattern as a monotype. Like @expr_ty, this function
561558 // doesn't provide type parameter substitutions.
562559 pub fn pat_ty ( & self , pat : & hir:: Pat ) -> Ty < ' tcx > {
563- self . node_id_to_type ( pat. hir_id )
560+ self . node_type ( pat. hir_id )
564561 }
565562
566563 pub fn pat_ty_opt ( & self , pat : & hir:: Pat ) -> Option < Ty < ' tcx > > {
567- self . node_id_to_type_opt ( pat. hir_id )
564+ self . node_type_opt ( pat. hir_id )
568565 }
569566
570567 // Returns the type of an expression as a monotype.
@@ -578,11 +575,11 @@ impl<'tcx> TypeckTables<'tcx> {
578575 // ask for the type of "id" in "id(3)", it will return "fn(&isize) -> isize"
579576 // instead of "fn(ty) -> T with T = isize".
580577 pub fn expr_ty ( & self , expr : & hir:: Expr ) -> Ty < ' tcx > {
581- self . node_id_to_type ( expr. hir_id )
578+ self . node_type ( expr. hir_id )
582579 }
583580
584581 pub fn expr_ty_opt ( & self , expr : & hir:: Expr ) -> Option < Ty < ' tcx > > {
585- self . node_id_to_type_opt ( expr. hir_id )
582+ self . node_type_opt ( expr. hir_id )
586583 }
587584
588585 pub fn adjustments ( & self ) -> LocalTableInContext < ' _ , Vec < ty:: adjustment:: Adjustment < ' tcx > > > {
0 commit comments