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