diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-24 13:47:35 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-24 13:47:35 +0900 |
| commit | 6b618c82ba6e124dbc84419e43670f702735b076 (patch) | |
| tree | 0440a9d27cfc2e3c3047c4565736eb6a25334198 /compiler | |
| parent | 0fa4f0ba6207ac8c8d1503f14f284d38b8fef81c (diff) | |
| parent | 0bb6bc40ce8d544ca41006d3faf8bcda2152030f (diff) | |
| download | rust-6b618c82ba6e124dbc84419e43670f702735b076.tar.gz rust-6b618c82ba6e124dbc84419e43670f702735b076.zip | |
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.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_driver/src/lib.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index b943977e4c2..87bc829b488 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -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; |
