about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-10-08 13:54:03 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-10-08 13:54:03 -0400
commit252c3838df76fbce4e282615d2685d916c75ba0f (patch)
tree8582e5e766614178a52b6454e4a31dc4d5ef969b
parent95285c496f58a326eace11bddb25a7ce7adcfe44 (diff)
parent5d015561836761e7a3d99e46dc91ccc7b6403e73 (diff)
downloadrust-252c3838df76fbce4e282615d2685d916c75ba0f.tar.gz
rust-252c3838df76fbce4e282615d2685d916c75ba0f.zip
Rollup merge of #28872 - iwillspeak:master, r=Manishearth
Currently the explain command line flag requires full error codes, complete with
the leading zeros and the E at the beginning. This commit changes that,
if you don't supply a full error code then the error number is padded
out to the required size and the E is added to the beginning.

This means that where previously you would need to write E0001, you can
now write 0001, 001, 01 or just 1 to refer to the same error.
-rw-r--r--src/librustc_driver/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index d5644d49e1e..e4f033efb58 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..]);