@@ -53,9 +53,10 @@ pub enum Node<'hir> {
53
53
NodeStmt ( & ' hir Stmt ) ,
54
54
NodeTy ( & ' hir Ty ) ,
55
55
NodeTraitRef ( & ' hir TraitRef ) ,
56
- NodeLocal ( & ' hir Pat ) ,
56
+ NodeBinding ( & ' hir Pat ) ,
57
57
NodePat ( & ' hir Pat ) ,
58
58
NodeBlock ( & ' hir Block ) ,
59
+ NodeLocal ( & ' hir Local ) ,
59
60
60
61
/// NodeStructCtor represents a tuple struct.
61
62
NodeStructCtor ( & ' hir VariantData ) ,
@@ -83,13 +84,14 @@ enum MapEntry<'hir> {
83
84
EntryStmt ( NodeId , & ' hir Stmt ) ,
84
85
EntryTy ( NodeId , & ' hir Ty ) ,
85
86
EntryTraitRef ( NodeId , & ' hir TraitRef ) ,
86
- EntryLocal ( NodeId , & ' hir Pat ) ,
87
+ EntryBinding ( NodeId , & ' hir Pat ) ,
87
88
EntryPat ( NodeId , & ' hir Pat ) ,
88
89
EntryBlock ( NodeId , & ' hir Block ) ,
89
90
EntryStructCtor ( NodeId , & ' hir VariantData ) ,
90
91
EntryLifetime ( NodeId , & ' hir Lifetime ) ,
91
92
EntryTyParam ( NodeId , & ' hir TyParam ) ,
92
93
EntryVisibility ( NodeId , & ' hir Visibility ) ,
94
+ EntryLocal ( NodeId , & ' hir Local ) ,
93
95
94
96
/// Roots for node trees.
95
97
RootCrate ,
@@ -114,13 +116,14 @@ impl<'hir> MapEntry<'hir> {
114
116
NodeStmt ( n) => EntryStmt ( p, n) ,
115
117
NodeTy ( n) => EntryTy ( p, n) ,
116
118
NodeTraitRef ( n) => EntryTraitRef ( p, n) ,
117
- NodeLocal ( n) => EntryLocal ( p, n) ,
119
+ NodeBinding ( n) => EntryBinding ( p, n) ,
118
120
NodePat ( n) => EntryPat ( p, n) ,
119
121
NodeBlock ( n) => EntryBlock ( p, n) ,
120
122
NodeStructCtor ( n) => EntryStructCtor ( p, n) ,
121
123
NodeLifetime ( n) => EntryLifetime ( p, n) ,
122
124
NodeTyParam ( n) => EntryTyParam ( p, n) ,
123
125
NodeVisibility ( n) => EntryVisibility ( p, n) ,
126
+ NodeLocal ( n) => EntryLocal ( p, n) ,
124
127
}
125
128
}
126
129
@@ -136,13 +139,14 @@ impl<'hir> MapEntry<'hir> {
136
139
EntryStmt ( id, _) => id,
137
140
EntryTy ( id, _) => id,
138
141
EntryTraitRef ( id, _) => id,
139
- EntryLocal ( id, _) => id,
142
+ EntryBinding ( id, _) => id,
140
143
EntryPat ( id, _) => id,
141
144
EntryBlock ( id, _) => id,
142
145
EntryStructCtor ( id, _) => id,
143
146
EntryLifetime ( id, _) => id,
144
147
EntryTyParam ( id, _) => id,
145
148
EntryVisibility ( id, _) => id,
149
+ EntryLocal ( id, _) => id,
146
150
147
151
NotPresent |
148
152
RootCrate => return None ,
@@ -161,13 +165,14 @@ impl<'hir> MapEntry<'hir> {
161
165
EntryStmt ( _, n) => NodeStmt ( n) ,
162
166
EntryTy ( _, n) => NodeTy ( n) ,
163
167
EntryTraitRef ( _, n) => NodeTraitRef ( n) ,
164
- EntryLocal ( _, n) => NodeLocal ( n) ,
168
+ EntryBinding ( _, n) => NodeBinding ( n) ,
165
169
EntryPat ( _, n) => NodePat ( n) ,
166
170
EntryBlock ( _, n) => NodeBlock ( n) ,
167
171
EntryStructCtor ( _, n) => NodeStructCtor ( n) ,
168
172
EntryLifetime ( _, n) => NodeLifetime ( n) ,
169
173
EntryTyParam ( _, n) => NodeTyParam ( n) ,
170
174
EntryVisibility ( _, n) => NodeVisibility ( n) ,
175
+ EntryLocal ( _, n) => NodeLocal ( n) ,
171
176
_ => return None
172
177
} )
173
178
}
@@ -319,13 +324,14 @@ impl<'hir> Map<'hir> {
319
324
EntryStmt ( p, _) |
320
325
EntryTy ( p, _) |
321
326
EntryTraitRef ( p, _) |
322
- EntryLocal ( p, _) |
327
+ EntryBinding ( p, _) |
323
328
EntryPat ( p, _) |
324
329
EntryBlock ( p, _) |
325
330
EntryStructCtor ( p, _) |
326
331
EntryLifetime ( p, _) |
327
332
EntryTyParam ( p, _) |
328
- EntryVisibility ( p, _) =>
333
+ EntryVisibility ( p, _) |
334
+ EntryLocal ( p, _) =>
329
335
id = p,
330
336
331
337
EntryExpr ( p, _) => {
@@ -589,7 +595,7 @@ impl<'hir> Map<'hir> {
589
595
/// immediate parent is an item or a closure.
590
596
pub fn is_argument ( & self , id : NodeId ) -> bool {
591
597
match self . find ( id) {
592
- Some ( NodeLocal ( _) ) => ( ) ,
598
+ Some ( NodeBinding ( _) ) => ( ) ,
593
599
_ => return false ,
594
600
}
595
601
match self . find ( self . get_parent_node ( id) ) {
@@ -856,7 +862,7 @@ impl<'hir> Map<'hir> {
856
862
NodeField ( f) => f. name ,
857
863
NodeLifetime ( lt) => lt. name ,
858
864
NodeTyParam ( tp) => tp. name ,
859
- NodeLocal ( & Pat { node : PatKind :: Binding ( _, _, l, _) , .. } ) => l. node ,
865
+ NodeBinding ( & Pat { node : PatKind :: Binding ( _, _, l, _) , .. } ) => l. node ,
860
866
NodeStructCtor ( _) => self . name ( self . get_parent ( id) ) ,
861
867
_ => bug ! ( "no name for {}" , self . node_to_string( id) )
862
868
}
@@ -915,14 +921,15 @@ impl<'hir> Map<'hir> {
915
921
Some ( EntryStmt ( _, stmt) ) => stmt. span ,
916
922
Some ( EntryTy ( _, ty) ) => ty. span ,
917
923
Some ( EntryTraitRef ( _, tr) ) => tr. path . span ,
918
- Some ( EntryLocal ( _, pat) ) => pat. span ,
924
+ Some ( EntryBinding ( _, pat) ) => pat. span ,
919
925
Some ( EntryPat ( _, pat) ) => pat. span ,
920
926
Some ( EntryBlock ( _, block) ) => block. span ,
921
927
Some ( EntryStructCtor ( _, _) ) => self . expect_item ( self . get_parent ( id) ) . span ,
922
928
Some ( EntryLifetime ( _, lifetime) ) => lifetime. span ,
923
929
Some ( EntryTyParam ( _, ty_param) ) => ty_param. span ,
924
930
Some ( EntryVisibility ( _, & Visibility :: Restricted { ref path, .. } ) ) => path. span ,
925
931
Some ( EntryVisibility ( _, v) ) => bug ! ( "unexpected Visibility {:?}" , v) ,
932
+ Some ( EntryLocal ( _, local) ) => local. span ,
926
933
927
934
Some ( RootCrate ) => self . forest . krate . span ,
928
935
Some ( NotPresent ) | None => {
@@ -1112,7 +1119,7 @@ impl<'a> print::State<'a> {
1112
1119
NodeStmt ( a) => self . print_stmt ( & a) ,
1113
1120
NodeTy ( a) => self . print_type ( & a) ,
1114
1121
NodeTraitRef ( a) => self . print_trait_ref ( & a) ,
1115
- NodeLocal ( a) |
1122
+ NodeBinding ( a) |
1116
1123
NodePat ( a) => self . print_pat ( & a) ,
1117
1124
NodeBlock ( a) => {
1118
1125
use syntax:: print:: pprust:: PrintState ;
@@ -1131,6 +1138,7 @@ impl<'a> print::State<'a> {
1131
1138
// hir_map to reconstruct their full structure for pretty
1132
1139
// printing.
1133
1140
NodeStructCtor ( _) => bug ! ( "cannot print isolated StructCtor" ) ,
1141
+ NodeLocal ( a) => self . print_local_decl ( & a) ,
1134
1142
}
1135
1143
}
1136
1144
}
@@ -1223,7 +1231,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
1223
1231
Some ( NodeTraitRef ( _) ) => {
1224
1232
format ! ( "trait_ref {}{}" , map. node_to_pretty_string( id) , id_str)
1225
1233
}
1226
- Some ( NodeLocal ( _) ) => {
1234
+ Some ( NodeBinding ( _) ) => {
1227
1235
format ! ( "local {}{}" , map. node_to_pretty_string( id) , id_str)
1228
1236
}
1229
1237
Some ( NodePat ( _) ) => {
@@ -1232,6 +1240,9 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
1232
1240
Some ( NodeBlock ( _) ) => {
1233
1241
format ! ( "block {}{}" , map. node_to_pretty_string( id) , id_str)
1234
1242
}
1243
+ Some ( NodeLocal ( _) ) => {
1244
+ format ! ( "local {}{}" , map. node_to_pretty_string( id) , id_str)
1245
+ }
1235
1246
Some ( NodeStructCtor ( _) ) => {
1236
1247
format ! ( "struct_ctor {}{}" , path_str( ) , id_str)
1237
1248
}
0 commit comments