@@ -400,6 +400,9 @@ struct HandlerInner {
400
400
emitter : Box < dyn Emitter + sync:: Send > ,
401
401
delayed_span_bugs : Vec < Diagnostic > ,
402
402
delayed_good_path_bugs : Vec < DelayedDiagnostic > ,
403
+ /// This flag indicates that an expected diagnostic was emitted and suppressed.
404
+ /// This is used for the `delayed_good_path_bugs` check.
405
+ suppressed_expected_diag : bool ,
403
406
404
407
/// This set contains the `DiagnosticId` of all emitted diagnostics to avoid
405
408
/// emitting the same diagnostic with extended help (`--teach`) twice, which
@@ -495,7 +498,7 @@ impl Drop for HandlerInner {
495
498
// instead of "require some error happened". Sadly that isn't ideal, as
496
499
// lints can be `#[allow]`'d, potentially leading to this triggering.
497
500
// Also, "good path" should be replaced with a better naming.
498
- if !self . has_any_message ( ) {
501
+ if !self . has_any_message ( ) && ! self . suppressed_expected_diag {
499
502
let bugs = std:: mem:: replace ( & mut self . delayed_good_path_bugs , Vec :: new ( ) ) ;
500
503
self . flush_delayed (
501
504
bugs. into_iter ( ) . map ( DelayedDiagnostic :: decorate) ,
@@ -577,6 +580,7 @@ impl Handler {
577
580
emitter,
578
581
delayed_span_bugs : Vec :: new ( ) ,
579
582
delayed_good_path_bugs : Vec :: new ( ) ,
583
+ suppressed_expected_diag : false ,
580
584
taught_diagnostics : Default :: default ( ) ,
581
585
emitted_diagnostic_codes : Default :: default ( ) ,
582
586
emitted_diagnostics : Default :: default ( ) ,
@@ -1000,20 +1004,20 @@ impl Handler {
1000
1004
let mut inner = self . inner . borrow_mut ( ) ;
1001
1005
let diags = std:: mem:: take ( & mut inner. unstable_expect_diagnostics ) ;
1002
1006
inner. check_unstable_expect_diagnostics = true ;
1003
- if diags. is_empty ( ) {
1004
- return ;
1005
- }
1006
1007
1007
- for mut diag in diags. into_iter ( ) {
1008
- diag. update_unstable_expectation_id ( unstable_to_stable) ;
1008
+ if !diags. is_empty ( ) {
1009
+ inner. suppressed_expected_diag = true ;
1010
+ for mut diag in diags. into_iter ( ) {
1011
+ diag. update_unstable_expectation_id ( unstable_to_stable) ;
1009
1012
1010
- let stable_id = diag
1011
- . level
1012
- . get_expectation_id ( )
1013
- . expect ( "all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`" ) ;
1014
- inner. fulfilled_expectations . insert ( stable_id) ;
1013
+ let stable_id = diag
1014
+ . level
1015
+ . get_expectation_id ( )
1016
+ . expect ( "all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`" ) ;
1017
+ inner. fulfilled_expectations . insert ( stable_id) ;
1015
1018
1016
- ( * TRACK_DIAGNOSTICS ) ( & diag) ;
1019
+ ( * TRACK_DIAGNOSTICS ) ( & diag) ;
1020
+ }
1017
1021
}
1018
1022
1019
1023
inner
@@ -1100,6 +1104,7 @@ impl HandlerInner {
1100
1104
( * TRACK_DIAGNOSTICS ) ( diagnostic) ;
1101
1105
1102
1106
if let Level :: Expect ( expectation_id) = diagnostic. level {
1107
+ self . suppressed_expected_diag = true ;
1103
1108
self . fulfilled_expectations . insert ( expectation_id) ;
1104
1109
return None ;
1105
1110
} else if diagnostic. level == Allow {
0 commit comments