@@ -708,7 +708,7 @@ impl DiagCtxt {
708
708
}
709
709
710
710
/// Emit all stashed diagnostics.
711
- pub fn emit_stashed_diagnostics ( & self ) -> Option < ErrorGuaranteed > {
711
+ pub fn emit_stashed_diagnostics ( & self ) {
712
712
self . inner . borrow_mut ( ) . emit_stashed_diagnostics ( )
713
713
}
714
714
@@ -931,8 +931,9 @@ impl DiagCtxt {
931
931
/// This excludes lint errors and delayed bugs.
932
932
pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
933
933
self . inner . borrow ( ) . has_errors ( ) . then ( || {
934
+ // FIXME(nnethercote) find a way to store an `ErrorGuaranteed`.
934
935
#[ allow( deprecated) ]
935
- ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
936
+ ErrorGuaranteed :: unchecked_error_guaranteed ( )
936
937
} )
937
938
}
938
939
@@ -942,8 +943,9 @@ impl DiagCtxt {
942
943
let inner = self . inner . borrow ( ) ;
943
944
let result = inner. has_errors ( ) || inner. lint_err_count > 0 ;
944
945
result. then ( || {
946
+ // FIXME(nnethercote) find a way to store an `ErrorGuaranteed`.
945
947
#[ allow( deprecated) ]
946
- ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
948
+ ErrorGuaranteed :: unchecked_error_guaranteed ( )
947
949
} )
948
950
}
949
951
@@ -954,8 +956,9 @@ impl DiagCtxt {
954
956
let result =
955
957
inner. has_errors ( ) || inner. lint_err_count > 0 || !inner. delayed_bugs . is_empty ( ) ;
956
958
result. then ( || {
959
+ // FIXME(nnethercote) find a way to store an `ErrorGuaranteed`.
957
960
#[ allow( deprecated) ]
958
- ErrorGuaranteed :: unchecked_claim_error_was_emitted ( )
961
+ ErrorGuaranteed :: unchecked_error_guaranteed ( )
959
962
} )
960
963
}
961
964
@@ -1216,9 +1219,8 @@ impl DiagCtxt {
1216
1219
// `DiagCtxtInner::foo`.
1217
1220
impl DiagCtxtInner {
1218
1221
/// Emit all stashed diagnostics.
1219
- fn emit_stashed_diagnostics ( & mut self ) -> Option < ErrorGuaranteed > {
1222
+ fn emit_stashed_diagnostics ( & mut self ) {
1220
1223
let has_errors = self . has_errors ( ) ;
1221
- let mut reported = None ;
1222
1224
for ( _, diag) in std:: mem:: take ( & mut self . stashed_diagnostics ) . into_iter ( ) {
1223
1225
// Decrement the count tracking the stash; emitting will increment it.
1224
1226
if diag. is_error ( ) {
@@ -1235,12 +1237,11 @@ impl DiagCtxtInner {
1235
1237
continue ;
1236
1238
}
1237
1239
}
1238
- let reported_this = self . emit_diagnostic ( diag) ;
1239
- reported = reported. or ( reported_this) ;
1240
+ self . emit_diagnostic ( diag) ;
1240
1241
}
1241
- reported
1242
1242
}
1243
1243
1244
+ // Return value is only `Some` if the level is `Error` or `DelayedBug`.
1244
1245
fn emit_diagnostic ( & mut self , mut diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1245
1246
assert ! ( diagnostic. level. can_be_top_or_sub( ) . 0 ) ;
1246
1247
@@ -1285,7 +1286,7 @@ impl DiagCtxtInner {
1285
1286
let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1286
1287
self . delayed_bugs . push ( DelayedDiagnostic :: with_backtrace ( diagnostic, backtrace) ) ;
1287
1288
#[ allow( deprecated) ]
1288
- return Some ( ErrorGuaranteed :: unchecked_claim_error_was_emitted ( ) ) ;
1289
+ return Some ( ErrorGuaranteed :: unchecked_error_guaranteed ( ) ) ;
1289
1290
}
1290
1291
GoodPathDelayedBug => {
1291
1292
let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
@@ -1319,6 +1320,7 @@ impl DiagCtxtInner {
1319
1320
!self . emitted_diagnostics . insert ( diagnostic_hash)
1320
1321
} ;
1321
1322
1323
+ let level = diagnostic. level ;
1322
1324
let is_error = diagnostic. is_error ( ) ;
1323
1325
let is_lint = diagnostic. is_lint . is_some ( ) ;
1324
1326
@@ -1355,18 +1357,19 @@ impl DiagCtxtInner {
1355
1357
1356
1358
self . emitter . emit_diagnostic ( diagnostic) ;
1357
1359
}
1360
+
1358
1361
if is_error {
1359
1362
if is_lint {
1360
1363
self . lint_err_count += 1 ;
1361
1364
} else {
1362
1365
self . err_count += 1 ;
1363
1366
}
1364
1367
self . panic_if_treat_err_as_bug ( ) ;
1368
+ }
1365
1369
1366
- #[ allow( deprecated) ]
1367
- {
1368
- guaranteed = Some ( ErrorGuaranteed :: unchecked_claim_error_was_emitted ( ) ) ;
1369
- }
1370
+ #[ allow( deprecated) ]
1371
+ if level == Level :: Error {
1372
+ guaranteed = Some ( ErrorGuaranteed :: unchecked_error_guaranteed ( ) ) ;
1370
1373
}
1371
1374
} ) ;
1372
1375
0 commit comments