@@ -804,6 +804,10 @@ impl GlobalState {
804804 fn handle_flycheck_msg ( & mut self , message : flycheck:: Message ) {
805805 match message {
806806 flycheck:: Message :: AddDiagnostic { id, workspace_root, diagnostic } => {
807+ if !self . diagnostics_received {
808+ self . diagnostics . clear_check ( id) ;
809+ self . diagnostics_received = true ;
810+ }
807811 let snap = self . snapshot ( ) ;
808812 let diagnostics = crate :: diagnostics:: to_proto:: map_rust_diagnostic_to_lsp (
809813 & self . config . diagnostics_map ( ) ,
@@ -832,7 +836,7 @@ impl GlobalState {
832836 flycheck:: Message :: Progress { id, progress } => {
833837 let ( state, message) = match progress {
834838 flycheck:: Progress :: DidStart => {
835- self . diagnostics . clear_check ( id ) ;
839+ self . diagnostics_received = false ;
836840 ( Progress :: Begin , None )
837841 }
838842 flycheck:: Progress :: DidCheckCrate ( target) => ( Progress :: Report , Some ( target) ) ,
@@ -848,6 +852,9 @@ impl GlobalState {
848852 flycheck:: Progress :: DidFinish ( result) => {
849853 self . last_flycheck_error =
850854 result. err ( ) . map ( |err| format ! ( "cargo check failed to start: {err}" ) ) ;
855+ if !self . diagnostics_received {
856+ self . diagnostics . clear_check ( id) ;
857+ }
851858 ( Progress :: End , None )
852859 }
853860 } ;
0 commit comments