@@ -30,7 +30,10 @@ use rustc_codegen_ssa::CodegenResults;
3030use rustc_codegen_utils:: codegen_backend:: CodegenBackend ;
3131use rustc_data_structures:: profiling:: print_time_passes_entry;
3232use rustc_data_structures:: sync:: SeqCst ;
33- use rustc_errors:: { registry:: Registry , PResult } ;
33+ use rustc_errors:: {
34+ registry:: { InvalidErrorCode , Registry } ,
35+ PResult ,
36+ } ;
3437use rustc_feature:: { find_gated_cfg, UnstableFeatures } ;
3538use rustc_hir:: def_id:: LOCAL_CRATE ;
3639use rustc_interface:: util:: { collect_crate_types, get_builtin_codegen_backend} ;
@@ -522,11 +525,10 @@ fn stdout_isatty() -> bool {
522525fn handle_explain ( registry : Registry , code : & str , output : ErrorOutputType ) {
523526 let normalised =
524527 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) ) => {
527530 let mut is_in_code_block = false ;
528531 let mut text = String :: new ( ) ;
529-
530532 // Slice off the leading newline and print.
531533 for line in description. lines ( ) {
532534 let indent_level =
@@ -542,16 +544,18 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
542544 }
543545 text. push ( '\n' ) ;
544546 }
545-
546547 if stdout_isatty ( ) {
547548 show_content_with_pager ( & text) ;
548549 } else {
549550 print ! ( "{}" , text) ;
550551 }
551552 }
552- None => {
553+ Ok ( None ) => {
553554 early_error ( output, & format ! ( "no extended information for {}" , code) ) ;
554555 }
556+ Err ( InvalidErrorCode ) => {
557+ early_error ( output, & format ! ( "{} is not a valid error code" , code) ) ;
558+ }
555559 }
556560}
557561
0 commit comments