driver: Extract handling of --explain to separate function

This commit is contained in:
Kamal Marhubi 2016-02-08 15:53:05 -05:00
parent 9951ac4be9
commit 4c4bb5ff5c

View File

@ -329,15 +329,9 @@ pub trait CompilerCalls<'a> {
#[derive(Copy, Clone)]
pub struct RustcDefaultCalls;
impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
fn early_callback(&mut self,
matches: &getopts::Matches,
_sopts: &config::Options,
fn handle_explain(code: &str,
descriptions: &diagnostics::registry::Registry,
output: ErrorOutputType)
-> Compilation {
match matches.opt_str("explain") {
Some(ref code) => {
output: ErrorOutputType) {
let normalised = if !code.starts_with("E") {
format!("E{0:0>4}", code)
} else {
@ -352,12 +346,21 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
early_error(output, &format!("no extended information for {}", code));
}
}
}
impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
fn early_callback(&mut self,
matches: &getopts::Matches,
_sopts: &config::Options,
descriptions: &diagnostics::registry::Registry,
output: ErrorOutputType)
-> Compilation {
if let Some(ref code) = matches.opt_str("explain") {
handle_explain(code, descriptions, output);
return Compilation::Stop;
}
None => (),
}
return Compilation::Continue;
Compilation::Continue
}
fn no_input(&mut self,