@@ -193,7 +193,7 @@ pub enum Note {
193
193
// a consistent fashion. For more details, see the method `cat_pattern`
194
194
#[ derive( Clone , Debug , PartialEq ) ]
195
195
pub struct cmt_ < ' tcx > {
196
- pub id : ast :: NodeId , // id of expr/pat producing this value
196
+ pub hir_id : hir :: HirId , // HIR id of expr/pat producing this value
197
197
pub span : Span , // span of same expr/pat
198
198
pub cat : Categorization < ' tcx > , // categorization of expr
199
199
pub mutbl : MutabilityCategory , // mutability of expr as place
@@ -275,18 +275,18 @@ impl<'tcx> cmt_<'tcx> {
275
275
}
276
276
}
277
277
278
- pub trait ast_node {
279
- fn id ( & self ) -> ast :: NodeId ;
278
+ pub trait HirNode {
279
+ fn hir_id ( & self ) -> hir :: HirId ;
280
280
fn span ( & self ) -> Span ;
281
281
}
282
282
283
- impl ast_node for hir:: Expr {
284
- fn id ( & self ) -> ast :: NodeId { self . id }
283
+ impl HirNode for hir:: Expr {
284
+ fn hir_id ( & self ) -> hir :: HirId { self . hir_id }
285
285
fn span ( & self ) -> Span { self . span }
286
286
}
287
287
288
- impl ast_node for hir:: Pat {
289
- fn id ( & self ) -> ast :: NodeId { self . id }
288
+ impl HirNode for hir:: Pat {
289
+ fn hir_id ( & self ) -> hir :: HirId { self . hir_id }
290
290
fn span ( & self ) -> Span { self . span }
291
291
}
292
292
@@ -614,7 +614,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
614
614
ty : target,
615
615
mutbl : deref. mutbl ,
616
616
} ) ;
617
- self . cat_rvalue_node ( expr. id , expr. span , ref_ty)
617
+ self . cat_rvalue_node ( expr. hir_id , expr. span , ref_ty)
618
618
} else {
619
619
previous ( ) ?
620
620
} ) ;
@@ -629,7 +629,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
629
629
adjustment:: Adjust :: Borrow ( _) |
630
630
adjustment:: Adjust :: Unsize => {
631
631
// Result is an rvalue.
632
- Ok ( self . cat_rvalue_node ( expr. id , expr. span , target) )
632
+ Ok ( self . cat_rvalue_node ( expr. hir_id , expr. span , target) )
633
633
}
634
634
}
635
635
}
@@ -673,8 +673,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
673
673
}
674
674
675
675
hir:: ExprPath ( ref qpath) => {
676
- let def = self . tables . qpath_def ( qpath, expr. hir_id ) ;
677
- self . cat_def ( expr. id , expr. span , expr_ty, def)
676
+ let def = self . tables . qpath_def ( qpath, expr. hir_id ) ;
677
+ self . cat_def ( expr. hir_id , expr. span , expr_ty, def)
678
678
}
679
679
680
680
hir:: ExprType ( ref e, _) => {
@@ -692,35 +692,35 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
692
692
hir:: ExprLit ( ..) | hir:: ExprBreak ( ..) |
693
693
hir:: ExprContinue ( ..) | hir:: ExprStruct ( ..) | hir:: ExprRepeat ( ..) |
694
694
hir:: ExprInlineAsm ( ..) | hir:: ExprBox ( ..) => {
695
- Ok ( self . cat_rvalue_node ( expr. id ( ) , expr. span ( ) , expr_ty) )
695
+ Ok ( self . cat_rvalue_node ( expr. hir_id , expr. span , expr_ty) )
696
696
}
697
697
}
698
698
}
699
699
700
700
pub fn cat_def ( & self ,
701
- id : ast :: NodeId ,
701
+ hir_id : hir :: HirId ,
702
702
span : Span ,
703
703
expr_ty : Ty < ' tcx > ,
704
704
def : Def )
705
705
-> McResult < cmt_ < ' tcx > > {
706
- debug ! ( "cat_def: id={} expr={:?} def={:?}" ,
707
- id , expr_ty, def) ;
706
+ debug ! ( "cat_def: id={:? } expr={:?} def={:?}" ,
707
+ hir_id , expr_ty, def) ;
708
708
709
709
match def {
710
710
Def :: StructCtor ( ..) | Def :: VariantCtor ( ..) | Def :: Const ( ..) |
711
711
Def :: AssociatedConst ( ..) | Def :: Fn ( ..) | Def :: Method ( ..) => {
712
- Ok ( self . cat_rvalue_node ( id , span, expr_ty) )
712
+ Ok ( self . cat_rvalue_node ( hir_id , span, expr_ty) )
713
713
}
714
714
715
715
Def :: Static ( def_id, mutbl) => {
716
716
// `#[thread_local]` statics may not outlive the current function.
717
717
for attr in & self . tcx . get_attrs ( def_id) [ ..] {
718
718
if attr. check_name ( "thread_local" ) {
719
- return Ok ( self . cat_rvalue_node ( id , span, expr_ty) ) ;
719
+ return Ok ( self . cat_rvalue_node ( hir_id , span, expr_ty) ) ;
720
720
}
721
721
}
722
722
Ok ( cmt_ {
723
- id : id ,
723
+ hir_id ,
724
724
span : span,
725
725
cat : Categorization :: StaticItem ,
726
726
mutbl : if mutbl { McDeclared } else { McImmutable } ,
@@ -730,12 +730,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
730
730
}
731
731
732
732
Def :: Upvar ( var_id, _, fn_node_id) => {
733
- self . cat_upvar ( id , span, var_id, fn_node_id)
733
+ self . cat_upvar ( hir_id , span, var_id, fn_node_id)
734
734
}
735
735
736
736
Def :: Local ( vid) => {
737
737
Ok ( cmt_ {
738
- id ,
738
+ hir_id ,
739
739
span,
740
740
cat : Categorization :: Local ( vid) ,
741
741
mutbl : MutabilityCategory :: from_local ( self . tcx , self . tables , vid) ,
@@ -751,7 +751,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
751
751
// Categorize an upvar, complete with invisible derefs of closure
752
752
// environment and upvar reference as appropriate.
753
753
fn cat_upvar ( & self ,
754
- id : ast :: NodeId ,
754
+ hir_id : hir :: HirId ,
755
755
span : Span ,
756
756
var_id : ast:: NodeId ,
757
757
fn_node_id : ast:: NodeId )
@@ -818,7 +818,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
818
818
// from the environment (perhaps we should eventually desugar
819
819
// this field further, but it will do for now).
820
820
let cmt_result = cmt_ {
821
- id ,
821
+ hir_id ,
822
822
span,
823
823
cat : Categorization :: Upvar ( Upvar { id : upvar_id, kind : kind} ) ,
824
824
mutbl : var_mutbl,
@@ -834,10 +834,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
834
834
cmt_result
835
835
}
836
836
ty:: ClosureKind :: FnMut => {
837
- self . env_deref ( id , span, upvar_id, var_mutbl, ty:: MutBorrow , cmt_result)
837
+ self . env_deref ( hir_id , span, upvar_id, var_mutbl, ty:: MutBorrow , cmt_result)
838
838
}
839
839
ty:: ClosureKind :: Fn => {
840
- self . env_deref ( id , span, upvar_id, var_mutbl, ty:: ImmBorrow , cmt_result)
840
+ self . env_deref ( hir_id , span, upvar_id, var_mutbl, ty:: ImmBorrow , cmt_result)
841
841
}
842
842
} ;
843
843
@@ -852,7 +852,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
852
852
ty:: UpvarCapture :: ByRef ( upvar_borrow) => {
853
853
let ptr = BorrowedPtr ( upvar_borrow. kind , upvar_borrow. region ) ;
854
854
cmt_ {
855
- id ,
855
+ hir_id ,
856
856
span,
857
857
cat : Categorization :: Deref ( Rc :: new ( cmt_result) , ptr) ,
858
858
mutbl : MutabilityCategory :: from_borrow_kind ( upvar_borrow. kind ) ,
@@ -868,7 +868,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
868
868
}
869
869
870
870
fn env_deref ( & self ,
871
- id : ast :: NodeId ,
871
+ hir_id : hir :: HirId ,
872
872
span : Span ,
873
873
upvar_id : ty:: UpvarId ,
874
874
upvar_mutbl : MutabilityCategory ,
@@ -912,7 +912,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
912
912
}
913
913
914
914
let ret = cmt_ {
915
- id ,
915
+ hir_id ,
916
916
span,
917
917
cat : Categorization :: Deref ( Rc :: new ( cmt_result) , env_ptr) ,
918
918
mutbl : deref_mutbl,
@@ -936,17 +936,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
936
936
}
937
937
938
938
pub fn cat_rvalue_node ( & self ,
939
- id : ast :: NodeId ,
939
+ hir_id : hir :: HirId ,
940
940
span : Span ,
941
941
expr_ty : Ty < ' tcx > )
942
942
-> cmt_ < ' tcx > {
943
943
debug ! (
944
944
"cat_rvalue_node(id={:?}, span={:?}, expr_ty={:?})" ,
945
- id ,
945
+ hir_id ,
946
946
span,
947
947
expr_ty,
948
948
) ;
949
- let hir_id = self . tcx . hir . node_to_hir_id ( id) ;
950
949
let promotable = self . rvalue_promotable_map . as_ref ( ) . map ( |m| m. contains ( & hir_id. local_id ) )
951
950
. unwrap_or ( false ) ;
952
951
@@ -974,18 +973,18 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
974
973
} else {
975
974
self . temporary_scope ( hir_id. local_id )
976
975
} ;
977
- let ret = self . cat_rvalue ( id , span, re, expr_ty) ;
976
+ let ret = self . cat_rvalue ( hir_id , span, re, expr_ty) ;
978
977
debug ! ( "cat_rvalue_node ret {:?}" , ret) ;
979
978
ret
980
979
}
981
980
982
981
pub fn cat_rvalue ( & self ,
983
- cmt_id : ast :: NodeId ,
982
+ cmt_hir_id : hir :: HirId ,
984
983
span : Span ,
985
984
temp_scope : ty:: Region < ' tcx > ,
986
985
expr_ty : Ty < ' tcx > ) -> cmt_ < ' tcx > {
987
986
let ret = cmt_ {
988
- id : cmt_id ,
987
+ hir_id : cmt_hir_id ,
989
988
span : span,
990
989
cat : Categorization :: Rvalue ( temp_scope) ,
991
990
mutbl : McDeclared ,
@@ -996,15 +995,15 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
996
995
ret
997
996
}
998
997
999
- pub fn cat_field < N : ast_node > ( & self ,
998
+ pub fn cat_field < N : HirNode > ( & self ,
1000
999
node : & N ,
1001
1000
base_cmt : cmt < ' tcx > ,
1002
1001
f_index : usize ,
1003
1002
f_ident : ast:: Ident ,
1004
1003
f_ty : Ty < ' tcx > )
1005
1004
-> cmt_ < ' tcx > {
1006
1005
let ret = cmt_ {
1007
- id : node. id ( ) ,
1006
+ hir_id : node. hir_id ( ) ,
1008
1007
span : node. span ( ) ,
1009
1008
mutbl : base_cmt. mutbl . inherit ( ) ,
1010
1009
cat : Categorization :: Interior ( base_cmt,
@@ -1046,13 +1045,13 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1046
1045
mutbl,
1047
1046
} ) ;
1048
1047
1049
- let base_cmt = Rc :: new ( self . cat_rvalue_node ( expr. id , expr. span , ref_ty) ) ;
1048
+ let base_cmt = Rc :: new ( self . cat_rvalue_node ( expr. hir_id , expr. span , ref_ty) ) ;
1050
1049
self . cat_deref ( expr, base_cmt, note)
1051
1050
}
1052
1051
1053
1052
pub fn cat_deref (
1054
1053
& self ,
1055
- node : & impl ast_node ,
1054
+ node : & impl HirNode ,
1056
1055
base_cmt : cmt < ' tcx > ,
1057
1056
note : Note ,
1058
1057
) -> McResult < cmt_ < ' tcx > > {
@@ -1078,7 +1077,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1078
1077
ref ty => bug ! ( "unexpected type in cat_deref: {:?}" , ty)
1079
1078
} ;
1080
1079
let ret = cmt_ {
1081
- id : node. id ( ) ,
1080
+ hir_id : node. hir_id ( ) ,
1082
1081
span : node. span ( ) ,
1083
1082
// For unique ptrs, we inherit mutability from the owning reference.
1084
1083
mutbl : MutabilityCategory :: from_pointer_kind ( base_cmt. mutbl , ptr) ,
@@ -1090,7 +1089,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1090
1089
Ok ( ret)
1091
1090
}
1092
1091
1093
- fn cat_index < N : ast_node > ( & self ,
1092
+ fn cat_index < N : HirNode > ( & self ,
1094
1093
elt : & N ,
1095
1094
base_cmt : cmt < ' tcx > ,
1096
1095
element_ty : Ty < ' tcx > ,
@@ -1110,7 +1109,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1110
1109
//! presuming that `base_cmt` is not of fixed-length type.
1111
1110
//!
1112
1111
//! # Parameters
1113
- //! - `elt`: the AST node being indexed
1112
+ //! - `elt`: the HIR node being indexed
1114
1113
//! - `base_cmt`: the cmt of `elt`
1115
1114
1116
1115
let interior_elem = InteriorElement ( context) ;
@@ -1119,14 +1118,14 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1119
1118
return Ok ( ret) ;
1120
1119
}
1121
1120
1122
- pub fn cat_imm_interior < N : ast_node > ( & self ,
1121
+ pub fn cat_imm_interior < N : HirNode > ( & self ,
1123
1122
node : & N ,
1124
1123
base_cmt : cmt < ' tcx > ,
1125
1124
interior_ty : Ty < ' tcx > ,
1126
1125
interior : InteriorKind )
1127
1126
-> cmt_ < ' tcx > {
1128
1127
let ret = cmt_ {
1129
- id : node. id ( ) ,
1128
+ hir_id : node. hir_id ( ) ,
1130
1129
span : node. span ( ) ,
1131
1130
mutbl : base_cmt. mutbl . inherit ( ) ,
1132
1131
cat : Categorization :: Interior ( base_cmt, interior) ,
@@ -1137,7 +1136,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1137
1136
ret
1138
1137
}
1139
1138
1140
- pub fn cat_downcast_if_needed < N : ast_node > ( & self ,
1139
+ pub fn cat_downcast_if_needed < N : HirNode > ( & self ,
1141
1140
node : & N ,
1142
1141
base_cmt : cmt < ' tcx > ,
1143
1142
variant_did : DefId )
@@ -1147,7 +1146,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1147
1146
if self . tcx . adt_def ( base_did) . variants . len ( ) != 1 {
1148
1147
let base_ty = base_cmt. ty ;
1149
1148
let ret = Rc :: new ( cmt_ {
1150
- id : node. id ( ) ,
1149
+ hir_id : node. hir_id ( ) ,
1151
1150
span : node. span ( ) ,
1152
1151
mutbl : base_cmt. mutbl . inherit ( ) ,
1153
1152
cat : Categorization :: Downcast ( base_cmt, variant_did) ,
0 commit comments