@@ -1248,24 +1248,36 @@ impl DiagCtxtInner {
1248
1248
}
1249
1249
1250
1250
fn emit_diagnostic ( & mut self , mut diagnostic : Diagnostic ) -> Option < ErrorGuaranteed > {
1251
- // The `LintExpectationId` can be stable or unstable depending on when it was created.
1252
- // Diagnostics created before the definition of `HirId`s are unstable and can not yet
1253
- // be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
1254
- // a stable one by the `LintLevelsBuilder`.
1255
- if let Some ( LintExpectationId :: Unstable { .. } ) = diagnostic. level . get_expectation_id ( ) {
1256
- self . unstable_expect_diagnostics . push ( diagnostic. clone ( ) ) ;
1257
- return None ;
1251
+ if let Some ( expectation_id) = diagnostic. level . get_expectation_id ( ) {
1252
+ // The `LintExpectationId` can be stable or unstable depending on when it was created.
1253
+ // Diagnostics created before the definition of `HirId`s are unstable and can not yet
1254
+ // be stored. Instead, they are buffered until the `LintExpectationId` is replaced by
1255
+ // a stable one by the `LintLevelsBuilder`.
1256
+ if let LintExpectationId :: Unstable { .. } = expectation_id {
1257
+ self . unstable_expect_diagnostics . push ( diagnostic. clone ( ) ) ;
1258
+ return None ;
1259
+ }
1260
+ self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
1261
+ }
1262
+
1263
+ if diagnostic. has_future_breakage ( ) {
1264
+ self . future_breakage_diagnostics . push ( diagnostic. clone ( ) ) ;
1265
+ }
1266
+
1267
+ if matches ! ( diagnostic. level, DelayedBug ( _) ) && self . flags . eagerly_emit_delayed_bugs {
1268
+ diagnostic. level = Error ;
1258
1269
}
1259
1270
1260
- // FIXME(eddyb) this should check for `has_errors` and stop pushing
1261
- // once *any* errors were emitted (and truncate `span_delayed_bugs`
1262
- // when an error is first emitted, also), but maybe there's a case
1263
- // in which that's not sound? otherwise this is really inefficient.
1264
1271
match diagnostic. level {
1265
- DelayedBug ( _) if self . flags . eagerly_emit_delayed_bugs => {
1266
- diagnostic. level = Error ;
1272
+ // This must come after the possible promotion of `DelayedBug` to `Error` above.
1273
+ Fatal | Error if self . treat_next_err_as_bug ( ) => {
1274
+ diagnostic. level = Bug ;
1267
1275
}
1268
1276
DelayedBug ( DelayedBugKind :: Normal ) => {
1277
+ // FIXME(eddyb) this should check for `has_errors` and stop pushing
1278
+ // once *any* errors were emitted (and truncate `span_delayed_bugs`
1279
+ // when an error is first emitted, also), but maybe there's a case
1280
+ // in which that's not sound? otherwise this is really inefficient.
1269
1281
let backtrace = std:: backtrace:: Backtrace :: capture ( ) ;
1270
1282
self . span_delayed_bugs
1271
1283
. push ( DelayedDiagnostic :: with_backtrace ( diagnostic. clone ( ) , backtrace) ) ;
@@ -1280,39 +1292,22 @@ impl DiagCtxtInner {
1280
1292
1281
1293
return None ;
1282
1294
}
1283
- _ => { }
1284
- }
1285
-
1286
- // This must come after the possible promotion of `DelayedBug` to
1287
- // `Error` above.
1288
- if matches ! ( diagnostic. level, Error | Fatal ) && self . treat_next_err_as_bug ( ) {
1289
- diagnostic. level = Bug ;
1290
- }
1291
-
1292
- if diagnostic. has_future_breakage ( ) {
1293
- self . future_breakage_diagnostics . push ( diagnostic. clone ( ) ) ;
1294
- }
1295
-
1296
- if let Some ( expectation_id) = diagnostic. level . get_expectation_id ( ) {
1297
- self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
1298
- }
1299
-
1300
- if diagnostic. level == Warning && !self . flags . can_emit_warnings {
1301
- if diagnostic. has_future_breakage ( ) {
1295
+ Warning if !self . flags . can_emit_warnings => {
1296
+ if diagnostic. has_future_breakage ( ) {
1297
+ ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1298
+ }
1299
+ return None ;
1300
+ }
1301
+ Allow => {
1302
1302
( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1303
+ return None ;
1303
1304
}
1304
- return None ;
1305
- }
1306
-
1307
- if matches ! ( diagnostic. level, Expect ( _) ) {
1308
- self . suppressed_expected_diag = true ;
1309
- ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1310
- return None ;
1311
- }
1312
-
1313
- if matches ! ( diagnostic. level, Allow ) {
1314
- ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1315
- return None ;
1305
+ Expect ( _) => {
1306
+ self . suppressed_expected_diag = true ;
1307
+ ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1308
+ return None ;
1309
+ }
1310
+ _ => { }
1316
1311
}
1317
1312
1318
1313
let mut guaranteed = None ;
0 commit comments