@@ -233,6 +233,7 @@ struct FlycheckActor {
233233 /// The receiver side of the channel mentioned above.
234234 command_receiver : Option < Receiver < CargoCheckMessage > > ,
235235 diagnostics_cleared_for : FxHashSet < Arc < PackageId > > ,
236+ diagnostics_cleared_for_all : bool ,
236237 diagnostics_received : bool ,
237238}
238239
@@ -264,6 +265,7 @@ impl FlycheckActor {
264265 command_handle : None ,
265266 command_receiver : None ,
266267 diagnostics_cleared_for : Default :: default ( ) ,
268+ diagnostics_cleared_for_all : false ,
267269 diagnostics_received : false ,
268270 }
269271 }
@@ -350,6 +352,7 @@ impl FlycheckActor {
350352 package_id : None ,
351353 } ) ;
352354 }
355+ self . clear_diagnostics_state ( ) ;
353356
354357 self . report_progress ( Progress :: DidFinish ( res) ) ;
355358 }
@@ -395,6 +398,12 @@ impl FlycheckActor {
395398 package_id : Some ( package_id. clone ( ) ) ,
396399 } ) ;
397400 }
401+ } else if !self . diagnostics_cleared_for_all {
402+ self . diagnostics_cleared_for_all = true ;
403+ self . send ( FlycheckMessage :: ClearDiagnostics {
404+ id : self . id ,
405+ package_id : None ,
406+ } ) ;
398407 }
399408 self . send ( FlycheckMessage :: AddDiagnostic {
400409 id : self . id ,
@@ -420,7 +429,12 @@ impl FlycheckActor {
420429 self . command_receiver . take ( ) ;
421430 self . report_progress ( Progress :: DidCancel ) ;
422431 }
432+ self . clear_diagnostics_state ( ) ;
433+ }
434+
435+ fn clear_diagnostics_state ( & mut self ) {
423436 self . diagnostics_cleared_for . clear ( ) ;
437+ self . diagnostics_cleared_for_all = false ;
424438 self . diagnostics_received = false ;
425439 }
426440
0 commit comments