Skip to content

Commit

Permalink
rustc: remove a trait that is unnecessary after pretty move.
Browse files Browse the repository at this point in the history
The type in the `impl` is now in the module with the trait.
  • Loading branch information
huonw committed Aug 29, 2014
1 parent 149032a commit ddc8cc9
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions src/librustc/driver/pretty.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) |
Expand Down

0 comments on commit ddc8cc9

Please sign in to comment.