@@ -30,7 +30,10 @@ use rustc_codegen_ssa::CodegenResults;
30
30
use rustc_codegen_utils:: codegen_backend:: CodegenBackend ;
31
31
use rustc_data_structures:: profiling:: print_time_passes_entry;
32
32
use rustc_data_structures:: sync:: SeqCst ;
33
- use rustc_errors:: { registry:: Registry , PResult } ;
33
+ use rustc_errors:: {
34
+ registry:: { InvalidErrorCode , Registry } ,
35
+ PResult ,
36
+ } ;
34
37
use rustc_feature:: { find_gated_cfg, UnstableFeatures } ;
35
38
use rustc_hir:: def_id:: LOCAL_CRATE ;
36
39
use rustc_interface:: util:: { collect_crate_types, get_builtin_codegen_backend} ;
@@ -522,11 +525,10 @@ fn stdout_isatty() -> bool {
522
525
fn handle_explain ( registry : Registry , code : & str , output : ErrorOutputType ) {
523
526
let normalised =
524
527
if code. starts_with ( 'E' ) { code. to_string ( ) } else { format ! ( "E{0:0>4}" , code) } ;
525
- match registry. find_description ( & normalised) {
526
- Some ( ref description) => {
528
+ match registry. try_find_description ( & normalised) {
529
+ Ok ( Some ( description) ) => {
527
530
let mut is_in_code_block = false ;
528
531
let mut text = String :: new ( ) ;
529
-
530
532
// Slice off the leading newline and print.
531
533
for line in description. lines ( ) {
532
534
let indent_level =
@@ -542,16 +544,18 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
542
544
}
543
545
text. push ( '\n' ) ;
544
546
}
545
-
546
547
if stdout_isatty ( ) {
547
548
show_content_with_pager ( & text) ;
548
549
} else {
549
550
print ! ( "{}" , text) ;
550
551
}
551
552
}
552
- None => {
553
+ Ok ( None ) => {
553
554
early_error ( output, & format ! ( "no extended information for {}" , code) ) ;
554
555
}
556
+ Err ( InvalidErrorCode ) => {
557
+ early_error ( output, & format ! ( "{} is not a valid error code" , code) ) ;
558
+ }
555
559
}
556
560
}
557
561
0 commit comments