Skip to content

Commit a5232b8

Browse files
committed
added error handle for error code > 9999
1 parent 651e9cf commit a5232b8

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, col
463463
// Allow "E0123" or "0123" form.
464464
let upper_cased_code = code.to_ascii_uppercase();
465465
if let Ok(code) = upper_cased_code.strip_prefix('E').unwrap_or(&upper_cased_code).parse::<u32>()
466+
&& code <= ErrCode::MAX_AS_U32
466467
&& let Ok(description) = registry.try_find_description(ErrCode::from_u32(code))
467468
{
468469
let mut is_in_code_block = false;

tests/ui/explain-with-error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//@ compile-flags: --explain E10000
2+
//~? ERROR: E10000 is not a valid error code

tests/ui/explain-with-error.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error: E10000 is not a valid error code

0 commit comments

Comments
 (0)