1
Fork 0

Rollup merge of #86533 - inquisitivecrystal:lower-case-error-explain, 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.
This commit is contained in:
Yuki Okushi 2021-06-24 13:47:35 +09:00 committed by GitHub
commit 6b618c82ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;