@@ -42,6 +42,7 @@ pub enum PpSourceMode {
42
42
PpmTyped ,
43
43
PpmIdentified ,
44
44
PpmExpandedIdentified ,
45
+ PpmExpandedHygiene ,
45
46
}
46
47
47
48
#[ deriving( PartialEq , Show ) ]
@@ -59,6 +60,7 @@ pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifie
59
60
"expanded" => PpmSource ( PpmExpanded ) ,
60
61
"typed" => PpmSource ( PpmTyped ) ,
61
62
"expanded,identified" => PpmSource ( PpmExpandedIdentified ) ,
63
+ "expanded,hygiene" => PpmSource ( PpmExpandedHygiene ) ,
62
64
"identified" => PpmSource ( PpmIdentified ) ,
63
65
"flowgraph" => PpmFlowGraph ,
64
66
_ => {
@@ -106,6 +108,10 @@ impl PpSourceMode {
106
108
let annotation = IdentifiedAnnotation { sess : sess, ast_map : ast_map } ;
107
109
f ( & annotation, payload)
108
110
}
111
+ PpmExpandedHygiene => {
112
+ let annotation = HygieneAnnotation { sess : sess, ast_map : ast_map } ;
113
+ f ( & annotation, payload)
114
+ }
109
115
PpmTyped => {
110
116
let ast_map = ast_map. expect ( "--pretty=typed missing ast_map" ) ;
111
117
let analysis = driver:: phase_3_run_analysis_passes ( sess, krate, ast_map, id) ;
@@ -191,6 +197,8 @@ impl pprust::PpAnn for IdentifiedAnnotation {
191
197
s : & mut pprust:: State ,
192
198
node : pprust:: AnnNode ) -> io:: IoResult < ( ) > {
193
199
match node {
200
+ pprust:: NodeIdent ( _) | pprust:: NodeName ( _) => Ok ( ( ) ) ,
201
+
194
202
pprust:: NodeItem ( item) => {
195
203
try!( pp:: space ( & mut s. s ) ) ;
196
204
s. synth_comment ( item. id . to_string ( ) )
@@ -212,6 +220,46 @@ impl pprust::PpAnn for IdentifiedAnnotation {
212
220
}
213
221
}
214
222
223
+ struct HygieneAnnotation {
224
+ sess : Session ,
225
+ ast_map : Option < ast_map:: Map > ,
226
+ }
227
+
228
+ impl PrinterSupport for HygieneAnnotation {
229
+ fn pp_ann < ' a > ( & ' a self ) -> & ' a pprust:: PpAnn { self as & pprust:: PpAnn }
230
+ }
231
+
232
+ impl SessionCarrier for HygieneAnnotation {
233
+ fn sess < ' a > ( & ' a self ) -> & ' a Session { & self . sess }
234
+ }
235
+
236
+ impl AstMapCarrier for HygieneAnnotation {
237
+ fn ast_map < ' a > ( & ' a self ) -> Option < & ' a ast_map:: Map > {
238
+ self . ast_map . as_ref ( )
239
+ }
240
+ }
241
+
242
+ impl pprust:: PpAnn for HygieneAnnotation {
243
+ fn post ( & self ,
244
+ s : & mut pprust:: State ,
245
+ node : pprust:: AnnNode ) -> io:: IoResult < ( ) > {
246
+ match node {
247
+ pprust:: NodeIdent ( & ast:: Ident { name : ast:: Name ( nm) , ctxt } ) => {
248
+ try!( pp:: space ( & mut s. s ) ) ;
249
+ // FIXME #16420: this doesn't display the connections
250
+ // between syntax contexts
251
+ s. synth_comment ( format ! ( "{}#{}" , nm, ctxt) )
252
+ }
253
+ pprust:: NodeName ( & ast:: Name ( nm) ) => {
254
+ try!( pp:: space ( & mut s. s ) ) ;
255
+ s. synth_comment ( nm. to_string ( ) )
256
+ }
257
+ _ => Ok ( ( ) )
258
+ }
259
+ }
260
+ }
261
+
262
+
215
263
struct TypedAnnotation {
216
264
analysis : CrateAnalysis ,
217
265
}
@@ -364,6 +412,7 @@ fn needs_ast_map(ppm: &PpMode, opt_uii: &Option<UserIdentifiedItem>) -> bool {
364
412
365
413
PpmSource ( PpmExpanded ) |
366
414
PpmSource ( PpmExpandedIdentified ) |
415
+ PpmSource ( PpmExpandedHygiene ) |
367
416
PpmSource ( PpmTyped ) |
368
417
PpmFlowGraph => true
369
418
}
@@ -376,6 +425,7 @@ fn needs_expansion(ppm: &PpMode) -> bool {
376
425
377
426
PpmSource ( PpmExpanded ) |
378
427
PpmSource ( PpmExpandedIdentified ) |
428
+ PpmSource ( PpmExpandedHygiene ) |
379
429
PpmSource ( PpmTyped ) |
380
430
PpmFlowGraph => true
381
431
}
0 commit comments