diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d5644d49e1ea4..e4f033efb58e3 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -285,7 +285,12 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls { -> Compilation { match matches.opt_str("explain") { Some(ref code) => { - match descriptions.find_description(&code[..]) { + let normalised = if !code.starts_with("E") { + format!("E{0:0>4}", code) + } else { + code.to_string() + }; + match descriptions.find_description(&normalised) { Some(ref description) => { // Slice off the leading newline and print. print!("{}", &description[1..]);