@@ -189,7 +189,7 @@ pub enum Note {
189
189
// fashion. For more details, see the method `cat_pattern`
190
190
#[ derive( Clone , Debug , PartialEq ) ]
191
191
pub struct cmt_ < ' tcx > {
192
- pub id : ast :: NodeId , // id of expr/pat producing this value
192
+ pub hir_id : hir :: HirId , // HIR id of expr/pat producing this value
193
193
pub span : Span , // span of same expr/pat
194
194
pub cat : Categorization < ' tcx > , // categorization of expr
195
195
pub mutbl : MutabilityCategory , // mutability of expr as place
@@ -271,18 +271,18 @@ impl<'tcx> cmt_<'tcx> {
271
271
}
272
272
}
273
273
274
- pub trait ast_node {
275
- fn id ( & self ) -> ast :: NodeId ;
274
+ pub trait HirNode {
275
+ fn hir_id ( & self ) -> hir :: HirId ;
276
276
fn span ( & self ) -> Span ;
277
277
}
278
278
279
- impl ast_node for hir:: Expr {
280
- fn id ( & self ) -> ast :: NodeId { self . id }
279
+ impl HirNode for hir:: Expr {
280
+ fn hir_id ( & self ) -> hir :: HirId { self . hir_id }
281
281
fn span ( & self ) -> Span { self . span }
282
282
}
283
283
284
- impl ast_node for hir:: Pat {
285
- fn id ( & self ) -> ast :: NodeId { self . id }
284
+ impl HirNode for hir:: Pat {
285
+ fn hir_id ( & self ) -> hir :: HirId { self . hir_id }
286
286
fn span ( & self ) -> Span { self . span }
287
287
}
288
288
@@ -610,7 +610,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
610
610
ty : target,
611
611
mutbl : deref. mutbl ,
612
612
} ) ;
613
- self . cat_rvalue_node ( expr. id , expr. span , ref_ty)
613
+ self . cat_rvalue_node ( expr. hir_id , expr. span , ref_ty)
614
614
} else {
615
615
previous ( ) ?
616
616
} ) ;
@@ -625,7 +625,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
625
625
adjustment:: Adjust :: Borrow ( _) |
626
626
adjustment:: Adjust :: Unsize => {
627
627
// Result is an rvalue.
628
- Ok ( self . cat_rvalue_node ( expr. id , expr. span , target) )
628
+ Ok ( self . cat_rvalue_node ( expr. hir_id , expr. span , target) )
629
629
}
630
630
}
631
631
}
@@ -669,8 +669,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
669
669
}
670
670
671
671
hir:: ExprPath ( ref qpath) => {
672
- let def = self . tables . qpath_def ( qpath, expr. hir_id ) ;
673
- self . cat_def ( expr. id , expr. span , expr_ty, def)
672
+ let def = self . tables . qpath_def ( qpath, expr. hir_id ) ;
673
+ self . cat_def ( expr. hir_id , expr. span , expr_ty, def)
674
674
}
675
675
676
676
hir:: ExprType ( ref e, _) => {
@@ -688,35 +688,35 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
688
688
hir:: ExprLit ( ..) | hir:: ExprBreak ( ..) |
689
689
hir:: ExprContinue ( ..) | hir:: ExprStruct ( ..) | hir:: ExprRepeat ( ..) |
690
690
hir:: ExprInlineAsm ( ..) | hir:: ExprBox ( ..) => {
691
- Ok ( self . cat_rvalue_node ( expr. id ( ) , expr. span ( ) , expr_ty) )
691
+ Ok ( self . cat_rvalue_node ( expr. hir_id , expr. span , expr_ty) )
692
692
}
693
693
}
694
694
}
695
695
696
696
pub fn cat_def ( & self ,
697
- id : ast :: NodeId ,
697
+ hir_id : hir :: HirId ,
698
698
span : Span ,
699
699
expr_ty : Ty < ' tcx > ,
700
700
def : Def )
701
701
-> McResult < cmt_ < ' tcx > > {
702
- debug ! ( "cat_def: id={} expr={:?} def={:?}" ,
703
- id , expr_ty, def) ;
702
+ debug ! ( "cat_def: id={:? } expr={:?} def={:?}" ,
703
+ hir_id , expr_ty, def) ;
704
704
705
705
match def {
706
706
Def :: StructCtor ( ..) | Def :: VariantCtor ( ..) | Def :: Const ( ..) |
707
707
Def :: AssociatedConst ( ..) | Def :: Fn ( ..) | Def :: Method ( ..) => {
708
- Ok ( self . cat_rvalue_node ( id , span, expr_ty) )
708
+ Ok ( self . cat_rvalue_node ( hir_id , span, expr_ty) )
709
709
}
710
710
711
711
Def :: Static ( def_id, mutbl) => {
712
712
// `#[thread_local]` statics may not outlive the current function.
713
713
for attr in & self . tcx . get_attrs ( def_id) [ ..] {
714
714
if attr. check_name ( "thread_local" ) {
715
- return Ok ( self . cat_rvalue_node ( id , span, expr_ty) ) ;
715
+ return Ok ( self . cat_rvalue_node ( hir_id , span, expr_ty) ) ;
716
716
}
717
717
}
718
718
Ok ( cmt_ {
719
- id : id ,
719
+ hir_id ,
720
720
span : span,
721
721
cat : Categorization :: StaticItem ,
722
722
mutbl : if mutbl { McDeclared } else { McImmutable } ,
@@ -726,12 +726,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
726
726
}
727
727
728
728
Def :: Upvar ( var_id, _, fn_node_id) => {
729
- self . cat_upvar ( id , span, var_id, fn_node_id)
729
+ self . cat_upvar ( hir_id , span, var_id, fn_node_id)
730
730
}
731
731
732
732
Def :: Local ( vid) => {
733
733
Ok ( cmt_ {
734
- id ,
734
+ hir_id ,
735
735
span,
736
736
cat : Categorization :: Local ( vid) ,
737
737
mutbl : MutabilityCategory :: from_local ( self . tcx , self . tables , vid) ,
@@ -747,7 +747,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
747
747
// Categorize an upvar, complete with invisible derefs of closure
748
748
// environment and upvar reference as appropriate.
749
749
fn cat_upvar ( & self ,
750
- id : ast :: NodeId ,
750
+ hir_id : hir :: HirId ,
751
751
span : Span ,
752
752
var_id : ast:: NodeId ,
753
753
fn_node_id : ast:: NodeId )
@@ -814,7 +814,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
814
814
// from the environment (perhaps we should eventually desugar
815
815
// this field further, but it will do for now).
816
816
let cmt_result = cmt_ {
817
- id ,
817
+ hir_id ,
818
818
span,
819
819
cat : Categorization :: Upvar ( Upvar { id : upvar_id, kind : kind} ) ,
820
820
mutbl : var_mutbl,
@@ -830,10 +830,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
830
830
cmt_result
831
831
}
832
832
ty:: ClosureKind :: FnMut => {
833
- self . env_deref ( id , span, upvar_id, var_mutbl, ty:: MutBorrow , cmt_result)
833
+ self . env_deref ( hir_id , span, upvar_id, var_mutbl, ty:: MutBorrow , cmt_result)
834
834
}
835
835
ty:: ClosureKind :: Fn => {
836
- self . env_deref ( id , span, upvar_id, var_mutbl, ty:: ImmBorrow , cmt_result)
836
+ self . env_deref ( hir_id , span, upvar_id, var_mutbl, ty:: ImmBorrow , cmt_result)
837
837
}
838
838
} ;
839
839
@@ -848,7 +848,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
848
848
ty:: UpvarCapture :: ByRef ( upvar_borrow) => {
849
849
let ptr = BorrowedPtr ( upvar_borrow. kind , upvar_borrow. region ) ;
850
850
cmt_ {
851
- id ,
851
+ hir_id ,
852
852
span,
853
853
cat : Categorization :: Deref ( Rc :: new ( cmt_result) , ptr) ,
854
854
mutbl : MutabilityCategory :: from_borrow_kind ( upvar_borrow. kind ) ,
@@ -864,7 +864,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
864
864
}
865
865
866
866
fn env_deref ( & self ,
867
- id : ast :: NodeId ,
867
+ hir_id : hir :: HirId ,
868
868
span : Span ,
869
869
upvar_id : ty:: UpvarId ,
870
870
upvar_mutbl : MutabilityCategory ,
@@ -908,7 +908,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
908
908
}
909
909
910
910
let ret = cmt_ {
911
- id ,
911
+ hir_id ,
912
912
span,
913
913
cat : Categorization :: Deref ( Rc :: new ( cmt_result) , env_ptr) ,
914
914
mutbl : deref_mutbl,
@@ -932,17 +932,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
932
932
}
933
933
934
934
pub fn cat_rvalue_node ( & self ,
935
- id : ast :: NodeId ,
935
+ hir_id : hir :: HirId ,
936
936
span : Span ,
937
937
expr_ty : Ty < ' tcx > )
938
938
-> cmt_ < ' tcx > {
939
939
debug ! (
940
940
"cat_rvalue_node(id={:?}, span={:?}, expr_ty={:?})" ,
941
- id ,
941
+ hir_id ,
942
942
span,
943
943
expr_ty,
944
944
) ;
945
- let hir_id = self . tcx . hir . node_to_hir_id ( id) ;
946
945
let promotable = self . rvalue_promotable_map . as_ref ( ) . map ( |m| m. contains ( & hir_id. local_id ) )
947
946
. unwrap_or ( false ) ;
948
947
@@ -970,18 +969,18 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
970
969
} else {
971
970
self . temporary_scope ( hir_id. local_id )
972
971
} ;
973
- let ret = self . cat_rvalue ( id , span, re, expr_ty) ;
972
+ let ret = self . cat_rvalue ( hir_id , span, re, expr_ty) ;
974
973
debug ! ( "cat_rvalue_node ret {:?}" , ret) ;
975
974
ret
976
975
}
977
976
978
977
pub fn cat_rvalue ( & self ,
979
- cmt_id : ast :: NodeId ,
978
+ cmt_hir_id : hir :: HirId ,
980
979
span : Span ,
981
980
temp_scope : ty:: Region < ' tcx > ,
982
981
expr_ty : Ty < ' tcx > ) -> cmt_ < ' tcx > {
983
982
let ret = cmt_ {
984
- id : cmt_id ,
983
+ hir_id : cmt_hir_id ,
985
984
span : span,
986
985
cat : Categorization :: Rvalue ( temp_scope) ,
987
986
mutbl : McDeclared ,
@@ -992,15 +991,15 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
992
991
ret
993
992
}
994
993
995
- pub fn cat_field < N : ast_node > ( & self ,
994
+ pub fn cat_field < N : HirNode > ( & self ,
996
995
node : & N ,
997
996
base_cmt : cmt < ' tcx > ,
998
997
f_index : usize ,
999
998
f_ident : ast:: Ident ,
1000
999
f_ty : Ty < ' tcx > )
1001
1000
-> cmt_ < ' tcx > {
1002
1001
let ret = cmt_ {
1003
- id : node. id ( ) ,
1002
+ hir_id : node. hir_id ( ) ,
1004
1003
span : node. span ( ) ,
1005
1004
mutbl : base_cmt. mutbl . inherit ( ) ,
1006
1005
cat : Categorization :: Interior ( base_cmt,
@@ -1042,13 +1041,13 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1042
1041
mutbl,
1043
1042
} ) ;
1044
1043
1045
- let base_cmt = Rc :: new ( self . cat_rvalue_node ( expr. id , expr. span , ref_ty) ) ;
1044
+ let base_cmt = Rc :: new ( self . cat_rvalue_node ( expr. hir_id , expr. span , ref_ty) ) ;
1046
1045
self . cat_deref ( expr, base_cmt, note)
1047
1046
}
1048
1047
1049
1048
pub fn cat_deref (
1050
1049
& self ,
1051
- node : & impl ast_node ,
1050
+ node : & impl HirNode ,
1052
1051
base_cmt : cmt < ' tcx > ,
1053
1052
note : Note ,
1054
1053
) -> McResult < cmt_ < ' tcx > > {
@@ -1074,7 +1073,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1074
1073
ref ty => bug ! ( "unexpected type in cat_deref: {:?}" , ty)
1075
1074
} ;
1076
1075
let ret = cmt_ {
1077
- id : node. id ( ) ,
1076
+ hir_id : node. hir_id ( ) ,
1078
1077
span : node. span ( ) ,
1079
1078
// For unique ptrs, we inherit mutability from the owning reference.
1080
1079
mutbl : MutabilityCategory :: from_pointer_kind ( base_cmt. mutbl , ptr) ,
@@ -1086,7 +1085,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1086
1085
Ok ( ret)
1087
1086
}
1088
1087
1089
- fn cat_index < N : ast_node > ( & self ,
1088
+ fn cat_index < N : HirNode > ( & self ,
1090
1089
elt : & N ,
1091
1090
base_cmt : cmt < ' tcx > ,
1092
1091
element_ty : Ty < ' tcx > ,
@@ -1106,7 +1105,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1106
1105
//! presuming that `base_cmt` is not of fixed-length type.
1107
1106
//!
1108
1107
//! # Parameters
1109
- //! - `elt`: the AST node being indexed
1108
+ //! - `elt`: the HIR node being indexed
1110
1109
//! - `base_cmt`: the cmt of `elt`
1111
1110
1112
1111
let interior_elem = InteriorElement ( context) ;
@@ -1115,14 +1114,14 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1115
1114
return Ok ( ret) ;
1116
1115
}
1117
1116
1118
- pub fn cat_imm_interior < N : ast_node > ( & self ,
1117
+ pub fn cat_imm_interior < N : HirNode > ( & self ,
1119
1118
node : & N ,
1120
1119
base_cmt : cmt < ' tcx > ,
1121
1120
interior_ty : Ty < ' tcx > ,
1122
1121
interior : InteriorKind )
1123
1122
-> cmt_ < ' tcx > {
1124
1123
let ret = cmt_ {
1125
- id : node. id ( ) ,
1124
+ hir_id : node. hir_id ( ) ,
1126
1125
span : node. span ( ) ,
1127
1126
mutbl : base_cmt. mutbl . inherit ( ) ,
1128
1127
cat : Categorization :: Interior ( base_cmt, interior) ,
@@ -1133,7 +1132,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1133
1132
ret
1134
1133
}
1135
1134
1136
- pub fn cat_downcast_if_needed < N : ast_node > ( & self ,
1135
+ pub fn cat_downcast_if_needed < N : HirNode > ( & self ,
1137
1136
node : & N ,
1138
1137
base_cmt : cmt < ' tcx > ,
1139
1138
variant_did : DefId )
@@ -1143,7 +1142,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
1143
1142
if self . tcx . adt_def ( base_did) . variants . len ( ) != 1 {
1144
1143
let base_ty = base_cmt. ty ;
1145
1144
let ret = Rc :: new ( cmt_ {
1146
- id : node. id ( ) ,
1145
+ hir_id : node. hir_id ( ) ,
1147
1146
span : node. span ( ) ,
1148
1147
mutbl : base_cmt. mutbl . inherit ( ) ,
1149
1148
cat : Categorization :: Downcast ( base_cmt, variant_did) ,
0 commit comments