Skip to content

Commit 6b618c8

Browse files
authored
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.
2 parents 0fa4f0b + 0bb6bc4 commit 6b618c8

File tree

1 file changed

+6
-2
lines changed
  • compiler/rustc_driver/src

1 file changed

+6
-2
lines changed

compiler/rustc_driver/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,12 @@ fn stderr_isatty() -> bool {
528528
}
529529

530530
fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
531-
let normalised =
532-
if code.starts_with('E') { code.to_string() } else { format!("E{0:0>4}", code) };
531+
let upper_cased_code = code.to_ascii_uppercase();
532+
let normalised = if upper_cased_code.starts_with('E') {
533+
upper_cased_code
534+
} else {
535+
format!("E{0:0>4}", code)
536+
};
533537
match registry.try_find_description(&normalised) {
534538
Ok(Some(description)) => {
535539
let mut is_in_code_block = false;

0 commit comments

Comments
 (0)