@@ -49,6 +49,7 @@ pub enum Node<'ast> {
49
49
NodeExpr ( & ' ast Expr ) ,
50
50
NodeStmt ( & ' ast Stmt ) ,
51
51
NodeTy ( & ' ast Ty ) ,
52
+ NodeTraitRef ( & ' ast TraitRef ) ,
52
53
NodeLocal ( & ' ast Pat ) ,
53
54
NodePat ( & ' ast Pat ) ,
54
55
NodeBlock ( & ' ast Block ) ,
@@ -57,7 +58,8 @@ pub enum Node<'ast> {
57
58
NodeStructCtor ( & ' ast VariantData ) ,
58
59
59
60
NodeLifetime ( & ' ast Lifetime ) ,
60
- NodeTyParam ( & ' ast TyParam )
61
+ NodeTyParam ( & ' ast TyParam ) ,
62
+ NodeVisibility ( & ' ast Visibility ) ,
61
63
}
62
64
63
65
/// Represents an entry and its parent NodeID.
@@ -76,12 +78,14 @@ pub enum MapEntry<'ast> {
76
78
EntryExpr ( NodeId , & ' ast Expr ) ,
77
79
EntryStmt ( NodeId , & ' ast Stmt ) ,
78
80
EntryTy ( NodeId , & ' ast Ty ) ,
81
+ EntryTraitRef ( NodeId , & ' ast TraitRef ) ,
79
82
EntryLocal ( NodeId , & ' ast Pat ) ,
80
83
EntryPat ( NodeId , & ' ast Pat ) ,
81
84
EntryBlock ( NodeId , & ' ast Block ) ,
82
85
EntryStructCtor ( NodeId , & ' ast VariantData ) ,
83
86
EntryLifetime ( NodeId , & ' ast Lifetime ) ,
84
87
EntryTyParam ( NodeId , & ' ast TyParam ) ,
88
+ EntryVisibility ( NodeId , & ' ast Visibility ) ,
85
89
86
90
/// Roots for node trees.
87
91
RootCrate ,
@@ -105,12 +109,14 @@ impl<'ast> MapEntry<'ast> {
105
109
NodeExpr ( n) => EntryExpr ( p, n) ,
106
110
NodeStmt ( n) => EntryStmt ( p, n) ,
107
111
NodeTy ( n) => EntryTy ( p, n) ,
112
+ NodeTraitRef ( n) => EntryTraitRef ( p, n) ,
108
113
NodeLocal ( n) => EntryLocal ( p, n) ,
109
114
NodePat ( n) => EntryPat ( p, n) ,
110
115
NodeBlock ( n) => EntryBlock ( p, n) ,
111
116
NodeStructCtor ( n) => EntryStructCtor ( p, n) ,
112
117
NodeLifetime ( n) => EntryLifetime ( p, n) ,
113
118
NodeTyParam ( n) => EntryTyParam ( p, n) ,
119
+ NodeVisibility ( n) => EntryVisibility ( p, n) ,
114
120
}
115
121
}
116
122
@@ -124,12 +130,14 @@ impl<'ast> MapEntry<'ast> {
124
130
EntryExpr ( id, _) => id,
125
131
EntryStmt ( id, _) => id,
126
132
EntryTy ( id, _) => id,
133
+ EntryTraitRef ( id, _) => id,
127
134
EntryLocal ( id, _) => id,
128
135
EntryPat ( id, _) => id,
129
136
EntryBlock ( id, _) => id,
130
137
EntryStructCtor ( id, _) => id,
131
138
EntryLifetime ( id, _) => id,
132
139
EntryTyParam ( id, _) => id,
140
+ EntryVisibility ( id, _) => id,
133
141
134
142
NotPresent |
135
143
RootCrate |
@@ -147,12 +155,14 @@ impl<'ast> MapEntry<'ast> {
147
155
EntryExpr ( _, n) => NodeExpr ( n) ,
148
156
EntryStmt ( _, n) => NodeStmt ( n) ,
149
157
EntryTy ( _, n) => NodeTy ( n) ,
158
+ EntryTraitRef ( _, n) => NodeTraitRef ( n) ,
150
159
EntryLocal ( _, n) => NodeLocal ( n) ,
151
160
EntryPat ( _, n) => NodePat ( n) ,
152
161
EntryBlock ( _, n) => NodeBlock ( n) ,
153
162
EntryStructCtor ( _, n) => NodeStructCtor ( n) ,
154
163
EntryLifetime ( _, n) => NodeLifetime ( n) ,
155
164
EntryTyParam ( _, n) => NodeTyParam ( n) ,
165
+ EntryVisibility ( _, n) => NodeVisibility ( n) ,
156
166
_ => return None
157
167
} )
158
168
}
@@ -266,12 +276,14 @@ impl<'ast> Map<'ast> {
266
276
EntryExpr ( p, _) |
267
277
EntryStmt ( p, _) |
268
278
EntryTy ( p, _) |
279
+ EntryTraitRef ( p, _) |
269
280
EntryLocal ( p, _) |
270
281
EntryPat ( p, _) |
271
282
EntryBlock ( p, _) |
272
283
EntryStructCtor ( p, _) |
273
284
EntryLifetime ( p, _) |
274
- EntryTyParam ( p, _) =>
285
+ EntryTyParam ( p, _) |
286
+ EntryVisibility ( p, _) =>
275
287
id = p,
276
288
277
289
RootCrate =>
@@ -307,12 +319,14 @@ impl<'ast> Map<'ast> {
307
319
EntryExpr ( p, _) |
308
320
EntryStmt ( p, _) |
309
321
EntryTy ( p, _) |
322
+ EntryTraitRef ( p, _) |
310
323
EntryLocal ( p, _) |
311
324
EntryPat ( p, _) |
312
325
EntryBlock ( p, _) |
313
326
EntryStructCtor ( p, _) |
314
327
EntryLifetime ( p, _) |
315
- EntryTyParam ( p, _) =>
328
+ EntryTyParam ( p, _) |
329
+ EntryVisibility ( p, _) =>
316
330
id = p,
317
331
318
332
RootInlinedParent ( parent) => match * parent {
@@ -707,11 +721,13 @@ impl<'ast> Map<'ast> {
707
721
Some ( NodeExpr ( expr) ) => expr. span ,
708
722
Some ( NodeStmt ( stmt) ) => stmt. span ,
709
723
Some ( NodeTy ( ty) ) => ty. span ,
724
+ Some ( NodeTraitRef ( tr) ) => tr. path . span ,
710
725
Some ( NodeLocal ( pat) ) => pat. span ,
711
726
Some ( NodePat ( pat) ) => pat. span ,
712
727
Some ( NodeBlock ( block) ) => block. span ,
713
728
Some ( NodeStructCtor ( _) ) => self . expect_item ( self . get_parent ( id) ) . span ,
714
729
Some ( NodeTyParam ( ty_param) ) => ty_param. span ,
730
+ Some ( NodeVisibility ( & Visibility :: Restricted { ref path, .. } ) ) => path. span ,
715
731
_ => return None ,
716
732
} ;
717
733
Some ( sp)
@@ -926,9 +942,11 @@ impl<'a> NodePrinter for pprust::State<'a> {
926
942
NodeExpr ( a) => self . print_expr ( & a) ,
927
943
NodeStmt ( a) => self . print_stmt ( & a) ,
928
944
NodeTy ( a) => self . print_type ( & a) ,
945
+ NodeTraitRef ( a) => self . print_trait_ref ( & a) ,
929
946
NodePat ( a) => self . print_pat ( & a) ,
930
947
NodeBlock ( a) => self . print_block ( & a) ,
931
948
NodeLifetime ( a) => self . print_lifetime ( & a) ,
949
+ NodeVisibility ( a) => self . print_visibility ( & a) ,
932
950
NodeTyParam ( _) => bug ! ( "cannot print TyParam" ) ,
933
951
// these cases do not carry enough information in the
934
952
// ast_map to reconstruct their full structure for pretty
@@ -1018,6 +1036,9 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
1018
1036
Some ( NodeTy ( ref ty) ) => {
1019
1037
format ! ( "type {}{}" , pprust:: ty_to_string( & ty) , id_str)
1020
1038
}
1039
+ Some ( NodeTraitRef ( ref tr) ) => {
1040
+ format ! ( "trait_ref {}{}" , pprust:: path_to_string( & tr. path) , id_str)
1041
+ }
1021
1042
Some ( NodeLocal ( ref pat) ) => {
1022
1043
format ! ( "local {}{}" , pprust:: pat_to_string( & pat) , id_str)
1023
1044
}
@@ -1037,6 +1058,9 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
1037
1058
Some ( NodeTyParam ( ref ty_param) ) => {
1038
1059
format ! ( "typaram {:?}{}" , ty_param, id_str)
1039
1060
}
1061
+ Some ( NodeVisibility ( ref vis) ) => {
1062
+ format ! ( "visibility {:?}{}" , vis, id_str)
1063
+ }
1040
1064
None => {
1041
1065
format ! ( "unknown node{}" , id_str)
1042
1066
}
0 commit comments