diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-03-16 15:54:04 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-03-17 07:06:10 +0000 |
| commit | a3e4dff1839e9ba70953b8a9ac8572a6cdb160b9 (patch) | |
| tree | 3dc7f99626d04ec860bf3f67de0551d5f0fb2d96 /compiler/rustc_driver_impl | |
| parent | 8b87fefd76665236a304d3c0998e1021710ce1b0 (diff) | |
| download | rust-a3e4dff1839e9ba70953b8a9ac8572a6cdb160b9.tar.gz rust-a3e4dff1839e9ba70953b8a9ac8572a6cdb160b9.zip | |
Use `strip_{prefix|suffix}` instead of `{starts|ends}_with`+indexing
Diffstat (limited to 'compiler/rustc_driver_impl')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index ed5662da16d..ea7e7a7c87a 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -457,8 +457,7 @@ pub enum Compilation { fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, color: ColorConfig) { // Allow "E0123" or "0123" form. let upper_cased_code = code.to_ascii_uppercase(); - let start = if upper_cased_code.starts_with('E') { 1 } else { 0 }; - if let Ok(code) = upper_cased_code[start..].parse::<u32>() + if let Ok(code) = upper_cased_code.strip_prefix('E').unwrap_or(&upper_cased_code).parse::<u32>() && let Ok(description) = registry.try_find_description(ErrCode::from_u32(code)) { let mut is_in_code_block = false; |
