@@ -1250,14 +1250,14 @@ impl HandlerInner {
1250
1250
1251
1251
fn treat_err_as_bug ( & self ) -> bool {
1252
1252
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 ( )
1258
1254
} )
1259
1255
}
1260
1256
1257
+ fn delayed_bug_count ( & self ) -> usize {
1258
+ self . delayed_span_bugs . len ( ) + self . delayed_good_path_bugs . len ( )
1259
+ }
1260
+
1261
1261
fn print_error_count ( & mut self , registry : & Registry ) {
1262
1262
self . emit_stashed_diagnostics ( ) ;
1263
1263
@@ -1412,12 +1412,7 @@ impl HandlerInner {
1412
1412
// incrementing `err_count` by one, so we need to +1 the comparing.
1413
1413
// FIXME: Would be nice to increment err_count in a more coherent way.
1414
1414
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 ( )
1421
1416
} ) {
1422
1417
// FIXME: don't abort here if report_delayed_bugs is off
1423
1418
self . span_bug ( sp, msg) ;
@@ -1518,14 +1513,24 @@ impl HandlerInner {
1518
1513
if self . treat_err_as_bug ( ) {
1519
1514
match (
1520
1515
self . err_count ( ) + self . lint_err_count ,
1516
+ self . delayed_bug_count ( ) ,
1521
1517
self . flags . treat_err_as_bug . map ( |c| c. get ( ) ) . unwrap_or ( 0 ) ,
1522
1518
) {
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
+ }
1529
1534
}
1530
1535
}
1531
1536
}
0 commit comments