@@ -87,15 +87,33 @@ pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifie
8787// (The `use_once_payload` is working around the current lack of once
8888// functions in the compiler.)
8989
90- trait CratePrinter {
90+ impl PpSourceMode {
9191 /// Constructs a `PrinterSupport` object and passes it to `f`.
9292 fn call_with_pp_support < A , B > ( & self ,
9393 sess : Session ,
9494 krate : & ast:: Crate ,
9595 ast_map : Option < ast_map:: Map > ,
9696 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+ }
99117}
100118
101119trait SessionCarrier {
@@ -339,34 +357,6 @@ impl UserIdentifiedItem {
339357 }
340358}
341359
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-
370360fn needs_ast_map ( ppm : & PpMode , opt_uii : & Option < UserIdentifiedItem > ) -> bool {
371361 match * ppm {
372362 PpmSource ( PpmNormal ) |
0 commit comments