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