Skip to content

Commit

Permalink
Rollup merge of #86533 - inquisitivecrystal:lower-case-error-explain,…
Browse files Browse the repository at this point in the history
… r=petrochenkov

Support lowercase error codes in `--explain`

This enables `rustc --explain` to accept a lowercase error code. Thus, for instance, `rustc --explain e0573` would be valid after this change, where before a user would have needed to do `rustc --explain E0573`. Although the upper case form of an error code is canonical, the user may prefer the easier-to-type lowercase form, and there's nothing to be gained by forcing them to type the upper case version.

Resolves #86518.
  • Loading branch information
JohnTitor committed Jun 24, 2021
2 parents 0fa4f0b + 0bb6bc4 commit 6b618c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_driver/src/lib.rs
Expand Up @@ -528,8 +528,12 @@ fn stderr_isatty() -> bool {
}

fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
let normalised =
if code.starts_with('E') { code.to_string() } else { format!("E{0:0>4}", code) };
let upper_cased_code = code.to_ascii_uppercase();
let normalised = if upper_cased_code.starts_with('E') {
upper_cased_code
} else {
format!("E{0:0>4}", code)
};
match registry.try_find_description(&normalised) {
Ok(Some(description)) => {
let mut is_in_code_block = false;
Expand Down

0 comments on commit 6b618c8

Please sign in to comment.