@@ -87,15 +87,33 @@ pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifie
87
87
// (The `use_once_payload` is working around the current lack of once
88
88
// functions in the compiler.)
89
89
90
- trait CratePrinter {
90
+ impl PpSourceMode {
91
91
/// Constructs a `PrinterSupport` object and passes it to `f`.
92
92
fn call_with_pp_support < A , B > ( & self ,
93
93
sess : Session ,
94
94
krate : & ast:: Crate ,
95
95
ast_map : Option < ast_map:: Map > ,
96
96
id : String ,
97
- use_once_payload : B ,
98
- f : |& PrinterSupport , B | -> A ) -> A ;
97
+ payload : B ,
98
+ f : |& PrinterSupport , B | -> A ) -> A {
99
+ match * self {
100
+ PpmNormal | PpmExpanded => {
101
+ let annotation = NoAnn { sess : sess, ast_map : ast_map } ;
102
+ f ( & annotation, payload)
103
+ }
104
+
105
+ PpmIdentified | PpmExpandedIdentified => {
106
+ let annotation = IdentifiedAnnotation { sess : sess, ast_map : ast_map } ;
107
+ f ( & annotation, payload)
108
+ }
109
+ PpmTyped => {
110
+ let ast_map = ast_map. expect ( "--pretty=typed missing ast_map" ) ;
111
+ let analysis = driver:: phase_3_run_analysis_passes ( sess, krate, ast_map, id) ;
112
+ let annotation = TypedAnnotation { analysis : analysis } ;
113
+ f ( & annotation, payload)
114
+ }
115
+ }
116
+ }
99
117
}
100
118
101
119
trait SessionCarrier {
@@ -339,34 +357,6 @@ impl UserIdentifiedItem {
339
357
}
340
358
}
341
359
342
- impl CratePrinter for PpSourceMode {
343
- fn call_with_pp_support < A , B > ( & self ,
344
- sess : Session ,
345
- krate : & ast:: Crate ,
346
- ast_map : Option < ast_map:: Map > ,
347
- id : String ,
348
- payload : B ,
349
- f : |& PrinterSupport , B | -> A ) -> A {
350
- match * self {
351
- PpmNormal | PpmExpanded => {
352
- let annotation = NoAnn { sess : sess, ast_map : ast_map } ;
353
- f ( & annotation, payload)
354
- }
355
-
356
- PpmIdentified | PpmExpandedIdentified => {
357
- let annotation = IdentifiedAnnotation { sess : sess, ast_map : ast_map } ;
358
- f ( & annotation, payload)
359
- }
360
- PpmTyped => {
361
- let ast_map = ast_map. expect ( "--pretty=typed missing ast_map" ) ;
362
- let analysis = driver:: phase_3_run_analysis_passes ( sess, krate, ast_map, id) ;
363
- let annotation = TypedAnnotation { analysis : analysis } ;
364
- f ( & annotation, payload)
365
- }
366
- }
367
- }
368
- }
369
-
370
360
fn needs_ast_map ( ppm : & PpMode , opt_uii : & Option < UserIdentifiedItem > ) -> bool {
371
361
match * ppm {
372
362
PpmSource ( PpmNormal ) |
0 commit comments