@@ -1250,14 +1250,14 @@ impl HandlerInner {
12501250
12511251 fn treat_err_as_bug ( & self ) -> bool {
12521252 self . flags . treat_err_as_bug . map_or ( false , |c| {
1253- self . err_count ( )
1254- + self . lint_err_count
1255- + self . delayed_span_bugs . len ( )
1256- + self . delayed_good_path_bugs . len ( )
1257- >= c. get ( )
1253+ self . err_count ( ) + self . lint_err_count + self . delayed_bug_count ( ) >= c. get ( )
12581254 } )
12591255 }
12601256
1257+ fn delayed_bug_count ( & self ) -> usize {
1258+ self . delayed_span_bugs . len ( ) + self . delayed_good_path_bugs . len ( )
1259+ }
1260+
12611261 fn print_error_count ( & mut self , registry : & Registry ) {
12621262 self . emit_stashed_diagnostics ( ) ;
12631263
@@ -1412,12 +1412,7 @@ impl HandlerInner {
14121412 // incrementing `err_count` by one, so we need to +1 the comparing.
14131413 // FIXME: Would be nice to increment err_count in a more coherent way.
14141414 if self . flags . treat_err_as_bug . map_or ( false , |c| {
1415- self . err_count ( )
1416- + self . lint_err_count
1417- + self . delayed_span_bugs . len ( )
1418- + self . delayed_good_path_bugs . len ( )
1419- + 1
1420- >= c. get ( )
1415+ self . err_count ( ) + self . lint_err_count + self . delayed_bug_count ( ) + 1 >= c. get ( )
14211416 } ) {
14221417 // FIXME: don't abort here if report_delayed_bugs is off
14231418 self . span_bug ( sp, msg) ;
@@ -1518,14 +1513,24 @@ impl HandlerInner {
15181513 if self . treat_err_as_bug ( ) {
15191514 match (
15201515 self . err_count ( ) + self . lint_err_count ,
1516+ self . delayed_bug_count ( ) ,
15211517 self . flags . treat_err_as_bug . map ( |c| c. get ( ) ) . unwrap_or ( 0 ) ,
15221518 ) {
1523- ( 1 , 1 ) => panic ! ( "aborting due to `-Z treat-err-as-bug=1`" ) ,
1524- ( 0 | 1 , _) => { }
1525- ( count, as_bug) => panic ! (
1526- "aborting after {} errors due to `-Z treat-err-as-bug={}`" ,
1527- count, as_bug,
1528- ) ,
1519+ ( 1 , 0 , 1 ) => panic ! ( "aborting due to `-Z treat-err-as-bug=1`" ) ,
1520+ ( 0 , 1 , 1 ) => panic ! ( "aborting due delayed bug with `-Z treat-err-as-bug=1`" ) ,
1521+ ( count, delayed_count, as_bug) => {
1522+ if delayed_count > 0 {
1523+ panic ! (
1524+ "aborting after {} errors and {} delayed bugs due to `-Z treat-err-as-bug={}`" ,
1525+ count, delayed_count, as_bug,
1526+ )
1527+ } else {
1528+ panic ! (
1529+ "aborting after {} errors due to `-Z treat-err-as-bug={}`" ,
1530+ count, as_bug,
1531+ )
1532+ }
1533+ }
15291534 }
15301535 }
15311536 }
0 commit comments