Auto merge of #13088 - Veykril:flycheck-failure, r=Veykril

Pop an error notification when flycheck can't be restarted
This commit is contained in:
bors 2022-08-22 15:43:13 +00:00
commit 6711ded5cd
2 changed files with 13 additions and 4 deletions

View File

@ -125,6 +125,7 @@ pub enum Progress {
DidCheckCrate(String), DidCheckCrate(String),
DidFinish(io::Result<()>), DidFinish(io::Result<()>),
DidCancel, DidCancel,
DidFailToRestart(String),
} }
enum Restart { enum Restart {
@ -193,10 +194,11 @@ fn run(mut self, inbox: Receiver<Restart>) {
self.progress(Progress::DidStart); self.progress(Progress::DidStart);
} }
Err(error) => { Err(error) => {
tracing::error!( self.progress(Progress::DidFailToRestart(format!(
command = ?self.check_command(), "Failed to run the following command: {:?} error={}",
%error, "failed to restart flycheck" self.check_command(),
); error
)));
} }
} }
} }

View File

@ -529,6 +529,13 @@ fn handle_flycheck_msg(&mut self, message: flycheck::Message) {
} }
flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)), flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)),
flycheck::Progress::DidCancel => (Progress::End, None), flycheck::Progress::DidCancel => (Progress::End, None),
flycheck::Progress::DidFailToRestart(err) => {
self.show_and_log_error(
"cargo check failed".to_string(),
Some(err.to_string()),
);
return;
}
flycheck::Progress::DidFinish(result) => { flycheck::Progress::DidFinish(result) => {
if let Err(err) = result { if let Err(err) = result {
self.show_and_log_error( self.show_and_log_error(