@@ -741,63 +741,42 @@ impl FlycheckActor {
741741 flycheck_id = self . id,
742742 message = diagnostic. message,
743743 package_id = package_id. as_ref( ) . map( |it| it. as_str( ) ) ,
744- scope = ?self . scope,
745744 "diagnostic received"
746745 ) ;
747-
748- match & self . scope {
749- FlycheckScope :: Workspace => {
750- if self . diagnostics_received == DiagnosticsReceived :: NotYet {
751- self . send ( FlycheckMessage :: ClearDiagnostics {
752- id : self . id ,
753- kind : ClearDiagnosticsKind :: All ( ClearScope :: Workspace ) ,
754- } ) ;
755-
756- self . diagnostics_received =
757- DiagnosticsReceived :: AtLeastOneAndClearedWorkspace ;
758- }
759-
760- self . send ( FlycheckMessage :: AddDiagnostic {
761- id : self . id ,
762- generation : self . generation ,
763- package_id : None ,
764- workspace_root : self . root . clone ( ) ,
765- diagnostic,
766- } ) ;
767- }
768- FlycheckScope :: Package { package : flycheck_package, .. } => {
769- if self . diagnostics_received == DiagnosticsReceived :: NotYet {
770- self . diagnostics_received = DiagnosticsReceived :: AtLeastOne ;
771- }
772-
773- // If the package has been set in the diagnostic JSON, respect that. Otherwise, use the
774- // package that the current flycheck is scoped to. This is useful when a project is
775- // directly using rustc for its checks (e.g. custom check commands in rust-project.json).
776- let package_id = package_id. unwrap_or ( flycheck_package. clone ( ) ) ;
777-
778- if self . diagnostics_cleared_for . insert ( package_id. clone ( ) ) {
779- tracing:: trace!(
780- flycheck_id = self . id,
781- package_id = package_id. as_str( ) ,
782- "clearing diagnostics"
783- ) ;
784- self . send ( FlycheckMessage :: ClearDiagnostics {
785- id : self . id ,
786- kind : ClearDiagnosticsKind :: All ( ClearScope :: Package (
787- package_id. clone ( ) ,
788- ) ) ,
789- } ) ;
790- }
791-
792- self . send ( FlycheckMessage :: AddDiagnostic {
746+ if self . diagnostics_received == DiagnosticsReceived :: NotYet {
747+ self . diagnostics_received = DiagnosticsReceived :: AtLeastOne ;
748+ }
749+ if let Some ( package_id) = & package_id {
750+ if self . diagnostics_cleared_for . insert ( package_id. clone ( ) ) {
751+ tracing:: trace!(
752+ flycheck_id = self . id,
753+ package_id = package_id. as_str( ) ,
754+ "clearing diagnostics"
755+ ) ;
756+ self . send ( FlycheckMessage :: ClearDiagnostics {
793757 id : self . id ,
794- generation : self . generation ,
795- package_id : Some ( package_id) ,
796- workspace_root : self . root . clone ( ) ,
797- diagnostic,
758+ kind : ClearDiagnosticsKind :: All ( ClearScope :: Package (
759+ package_id. clone ( ) ,
760+ ) ) ,
798761 } ) ;
799762 }
763+ } else if self . diagnostics_received
764+ != DiagnosticsReceived :: AtLeastOneAndClearedWorkspace
765+ {
766+ self . diagnostics_received =
767+ DiagnosticsReceived :: AtLeastOneAndClearedWorkspace ;
768+ self . send ( FlycheckMessage :: ClearDiagnostics {
769+ id : self . id ,
770+ kind : ClearDiagnosticsKind :: All ( ClearScope :: Workspace ) ,
771+ } ) ;
800772 }
773+ self . send ( FlycheckMessage :: AddDiagnostic {
774+ id : self . id ,
775+ generation : self . generation ,
776+ package_id,
777+ workspace_root : self . root . clone ( ) ,
778+ diagnostic,
779+ } ) ;
801780 }
802781 } ,
803782 }
0 commit comments