Skip to content

Commit 252c383

Browse files
committed
Rollup merge of rust-lang#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.
2 parents 95285c4 + 5d01556 commit 252c383

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustc_driver/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
285285
-> Compilation {
286286
match matches.opt_str("explain") {
287287
Some(ref code) => {
288-
match descriptions.find_description(&code[..]) {
288+
let normalised = if !code.starts_with("E") {
289+
format!("E{0:0>4}", code)
290+
} else {
291+
code.to_string()
292+
};
293+
match descriptions.find_description(&normalised) {
289294
Some(ref description) => {
290295
// Slice off the leading newline and print.
291296
print!("{}", &description[1..]);

0 commit comments

Comments
 (0)