@@ -329,35 +329,38 @@ pub trait CompilerCalls<'a> {
329
329
#[ derive( Copy , Clone ) ]
330
330
pub struct RustcDefaultCalls ;
331
331
332
+ fn handle_explain ( code : & str ,
333
+ descriptions : & diagnostics:: registry:: Registry ,
334
+ output : ErrorOutputType ) {
335
+ let normalised = if !code. starts_with ( "E" ) {
336
+ format ! ( "E{0:0>4}" , code)
337
+ } else {
338
+ code. to_string ( )
339
+ } ;
340
+ match descriptions. find_description ( & normalised) {
341
+ Some ( ref description) => {
342
+ // Slice off the leading newline and print.
343
+ print ! ( "{}" , & description[ 1 ..] ) ;
344
+ }
345
+ None => {
346
+ early_error ( output, & format ! ( "no extended information for {}" , code) ) ;
347
+ }
348
+ }
349
+ }
350
+
332
351
impl < ' a > CompilerCalls < ' a > for RustcDefaultCalls {
333
352
fn early_callback ( & mut self ,
334
353
matches : & getopts:: Matches ,
335
354
_sopts : & config:: Options ,
336
355
descriptions : & diagnostics:: registry:: Registry ,
337
356
output : ErrorOutputType )
338
357
-> Compilation {
339
- match matches. opt_str ( "explain" ) {
340
- Some ( ref code) => {
341
- let normalised = if !code. starts_with ( "E" ) {
342
- format ! ( "E{0:0>4}" , code)
343
- } else {
344
- code. to_string ( )
345
- } ;
346
- match descriptions. find_description ( & normalised) {
347
- Some ( ref description) => {
348
- // Slice off the leading newline and print.
349
- print ! ( "{}" , & description[ 1 ..] ) ;
350
- }
351
- None => {
352
- early_error ( output, & format ! ( "no extended information for {}" , code) ) ;
353
- }
354
- }
355
- return Compilation :: Stop ;
356
- }
357
- None => ( ) ,
358
+ if let Some ( ref code) = matches. opt_str ( "explain" ) {
359
+ handle_explain ( code, descriptions, output) ;
360
+ return Compilation :: Stop ;
358
361
}
359
362
360
- return Compilation :: Continue ;
363
+ Compilation :: Continue
361
364
}
362
365
363
366
fn no_input ( & mut self ,
0 commit comments