diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-08-11 21:12:23 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-08-29 18:05:26 +1000 |
| commit | ddc8cc92c998b7d80c782d00d178c791ab564915 (patch) | |
| tree | 26f7b5262f94413b9700ca89e8c1072f5adf8186 | |
| parent | 149032aff393de695c068c4cd907d99ec75a3f7a (diff) | |
| download | rust-ddc8cc92c998b7d80c782d00d178c791ab564915.tar.gz rust-ddc8cc92c998b7d80c782d00d178c791ab564915.zip | |
rustc: remove a trait that is unnecessary after pretty move.
The type in the `impl` is now in the module with the trait.
| -rw-r--r-- | src/librustc/driver/pretty.rs | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/src/librustc/driver/pretty.rs b/src/librustc/driver/pretty.rs index 8f2b56f9ce3..d7118c7e54c 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc/driver/pretty.rs @@ -87,15 +87,33 @@ pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifie // (The `use_once_payload` is working around the current lack of once // functions in the compiler.) -trait CratePrinter { +impl PpSourceMode { /// Constructs a `PrinterSupport` object and passes it to `f`. fn call_with_pp_support<A,B>(&self, sess: Session, krate: &ast::Crate, ast_map: Option<ast_map::Map>, id: String, - use_once_payload: B, - f: |&PrinterSupport, B| -> A) -> A; + payload: B, + f: |&PrinterSupport, B| -> A) -> A { + match *self { + PpmNormal | PpmExpanded => { + let annotation = NoAnn { sess: sess, ast_map: ast_map }; + f(&annotation, payload) + } + + PpmIdentified | PpmExpandedIdentified => { + let annotation = IdentifiedAnnotation { sess: sess, ast_map: ast_map }; + f(&annotation, payload) + } + PpmTyped => { + let ast_map = ast_map.expect("--pretty=typed missing ast_map"); + let analysis = driver::phase_3_run_analysis_passes(sess, krate, ast_map, id); + let annotation = TypedAnnotation { analysis: analysis }; + f(&annotation, payload) + } + } + } } trait SessionCarrier { @@ -339,34 +357,6 @@ impl UserIdentifiedItem { } } -impl CratePrinter for PpSourceMode { - fn call_with_pp_support<A,B>(&self, - sess: Session, - krate: &ast::Crate, - ast_map: Option<ast_map::Map>, - id: String, - payload: B, - f: |&PrinterSupport, B| -> A) -> A { - match *self { - PpmNormal | PpmExpanded => { - let annotation = NoAnn { sess: sess, ast_map: ast_map }; - f(&annotation, payload) - } - - PpmIdentified | PpmExpandedIdentified => { - let annotation = IdentifiedAnnotation { sess: sess, ast_map: ast_map }; - f(&annotation, payload) - } - PpmTyped => { - let ast_map = ast_map.expect("--pretty=typed missing ast_map"); - let analysis = driver::phase_3_run_analysis_passes(sess, krate, ast_map, id); - let annotation = TypedAnnotation { analysis: analysis }; - f(&annotation, payload) - } - } - } -} - fn needs_ast_map(ppm: &PpMode, opt_uii: &Option<UserIdentifiedItem>) -> bool { match *ppm { PpmSource(PpmNormal) | |
