@@ -137,7 +137,7 @@ use crate::TypeAndSubsts;
137137use crate :: lint;
138138use crate :: util:: captures:: Captures ;
139139use crate :: util:: common:: { ErrorReported , indenter} ;
140- use crate :: util:: nodemap:: { DefIdMap , DefIdSet , FxHashMap , FxHashSet , HirIdMap , NodeMap } ;
140+ use crate :: util:: nodemap:: { DefIdMap , DefIdSet , FxHashMap , FxHashSet , HirIdMap } ;
141141
142142pub use self :: Expectation :: * ;
143143use self :: autoderef:: Autoderef ;
@@ -194,7 +194,7 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
194194
195195 tables : MaybeInProgressTables < ' a , ' tcx > ,
196196
197- locals : RefCell < NodeMap < LocalTy < ' tcx > > > ,
197+ locals : RefCell < HirIdMap < LocalTy < ' tcx > > > ,
198198
199199 fulfillment_cx : RefCell < Box < dyn TraitEngine < ' tcx > > > ,
200200
@@ -943,7 +943,7 @@ struct GatherLocalsVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
943943}
944944
945945impl < ' a , ' gcx , ' tcx > GatherLocalsVisitor < ' a , ' gcx , ' tcx > {
946- fn assign ( & mut self , span : Span , nid : ast :: NodeId , ty_opt : Option < LocalTy < ' tcx > > ) -> Ty < ' tcx > {
946+ fn assign ( & mut self , span : Span , nid : hir :: HirId , ty_opt : Option < LocalTy < ' tcx > > ) -> Ty < ' tcx > {
947947 match ty_opt {
948948 None => {
949949 // infer the variable's type
@@ -994,19 +994,19 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
994994 } ,
995995 None => None ,
996996 } ;
997- self . assign ( local. span , local. id , local_ty) ;
997+ self . assign ( local. span , local. hir_id , local_ty) ;
998998
999999 debug ! ( "Local variable {:?} is assigned type {}" ,
10001000 local. pat,
10011001 self . fcx. ty_to_string(
1002- self . fcx. locals. borrow( ) . get( & local. id ) . unwrap( ) . clone( ) . decl_ty) ) ;
1002+ self . fcx. locals. borrow( ) . get( & local. hir_id ) . unwrap( ) . clone( ) . decl_ty) ) ;
10031003 intravisit:: walk_local ( self , local) ;
10041004 }
10051005
10061006 // Add pattern bindings.
10071007 fn visit_pat ( & mut self , p : & ' gcx hir:: Pat ) {
10081008 if let PatKind :: Binding ( _, _, _, ident, _) = p. node {
1009- let var_ty = self . assign ( p. span , p. id , None ) ;
1009+ let var_ty = self . assign ( p. span , p. hir_id , None ) ;
10101010
10111011 if !self . fcx . tcx . features ( ) . unsized_locals {
10121012 self . fcx . require_type_is_sized ( var_ty, p. span ,
@@ -1016,7 +1016,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
10161016 debug ! ( "Pattern binding {} is assigned to {} with type {:?}" ,
10171017 ident,
10181018 self . fcx. ty_to_string(
1019- self . fcx. locals. borrow( ) . get( & p. id ) . unwrap( ) . clone( ) . decl_ty) ,
1019+ self . fcx. locals. borrow( ) . get( & p. hir_id ) . unwrap( ) . clone( ) . decl_ty) ,
10201020 var_ty) ;
10211021 }
10221022 intravisit:: walk_pat ( self , p) ;
@@ -2124,10 +2124,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
21242124 format ! ( "{:?}" , self_ptr)
21252125 }
21262126
2127- pub fn local_ty ( & self , span : Span , nid : ast :: NodeId ) -> LocalTy < ' tcx > {
2127+ pub fn local_ty ( & self , span : Span , nid : hir :: HirId ) -> LocalTy < ' tcx > {
21282128 self . locals . borrow ( ) . get ( & nid) . cloned ( ) . unwrap_or_else ( ||
21292129 span_bug ! ( span, "no type for local variable {}" ,
2130- self . tcx. hir( ) . node_to_string ( nid) )
2130+ self . tcx. hir( ) . hir_to_string ( nid) )
21312131 )
21322132 }
21332133
@@ -4805,7 +4805,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
48054805 // See #44848.
48064806 let ref_bindings = local. pat . contains_explicit_ref_binding ( ) ;
48074807
4808- let local_ty = self . local_ty ( init. span , local. id ) . revealed_ty ;
4808+ let local_ty = self . local_ty ( init. span , local. hir_id ) . revealed_ty ;
48094809 if let Some ( m) = ref_bindings {
48104810 // Somewhat subtle: if we have a `ref` binding in the pattern,
48114811 // we want to avoid introducing coercions for the RHS. This is
@@ -4824,7 +4824,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
48244824 }
48254825
48264826 pub fn check_decl_local ( & self , local : & ' gcx hir:: Local ) {
4827- let t = self . local_ty ( local. span , local. id ) . decl_ty ;
4827+ let t = self . local_ty ( local. span , local. hir_id ) . decl_ty ;
48284828 self . write_ty ( local. hir_id , t) ;
48294829
48304830 if let Some ( ref init) = local. init {
@@ -5378,7 +5378,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
53785378
53795379 match def {
53805380 Def :: Local ( nid) | Def :: Upvar ( nid, ..) => {
5381- let ty = self . local_ty ( span, nid) . decl_ty ;
5381+ let hid = self . tcx . hir ( ) . node_to_hir_id ( nid) ;
5382+ let ty = self . local_ty ( span, hid) . decl_ty ;
53825383 let ty = self . normalize_associated_types_in ( span, & ty) ;
53835384 self . write_ty ( hir_id, ty) ;
53845385 return ( ty, def) ;
0 commit comments