Skip to content

Commit b3f20a8

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

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
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;

compiler/rustc_errors/src/codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use std::fmt;
88

99
rustc_index::newtype_index! {
10-
#[max = 9999] // Because all error codes have four digits.
10+
#[max = 9999]
1111
#[orderable]
1212
#[encodable]
1313
#[debug_format = "ErrCode({})"]

0 commit comments

Comments
 (0)