From 635270d4ad0e8c1b99784d8d46199fe0d2e8f956 Mon Sep 17 00:00:00 2001 From: Cadu Date: Sun, 3 Apr 2022 13:48:10 -0300 Subject: [PATCH 1/4] Better error message hinting about `cargo clippy` --- crates/flycheck/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 0a4f9d578a..7b643b992c 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -329,7 +329,7 @@ impl CargoActor { Ok(output) if output.status.success() => Ok(()), Ok(output) => { Err(io::Error::new(io::ErrorKind::Other, format!( - "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})", + "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nMake sure to have `cargo clippy` installed.", output.status ))) } From 8e5c57f050aad35e2c5653597a40c3e0ac762465 Mon Sep 17 00:00:00 2001 From: Cadu Date: Sun, 3 Apr 2022 14:06:36 -0300 Subject: [PATCH 2/4] wordsmithing. --- crates/flycheck/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 7b643b992c..1168f11f96 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -329,7 +329,7 @@ impl CargoActor { Ok(output) if output.status.success() => Ok(()), Ok(output) => { Err(io::Error::new(io::ErrorKind::Other, format!( - "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nMake sure to have `cargo clippy` installed.", + "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nMake sure you have `cargo clippy` installed and updated.", output.status ))) } From ca9718aa4285bc3cd697c44516af0dd8f98a1cf9 Mon Sep 17 00:00:00 2001 From: Cadu Date: Mon, 4 Apr 2022 19:14:33 -0300 Subject: [PATCH 3/4] Made error output the contents of Cargo's stderr as well. --- crates/flycheck/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 1168f11f96..b01f275cdc 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -2,7 +2,7 @@ //! another compatible command (f.x. clippy) in a background thread and provide //! LSP diagnostics based on the output of the command. -use std::{fmt, io, process::Command, time::Duration}; +use std::{fmt, io, process::Command, time::Duration, str::from_utf8}; use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; use paths::AbsPathBuf; @@ -329,8 +329,8 @@ impl CargoActor { Ok(output) if output.status.success() => Ok(()), Ok(output) => { Err(io::Error::new(io::ErrorKind::Other, format!( - "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nMake sure you have `cargo clippy` installed and updated.", - output.status + "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nCargo's stderr output:\n{}", + output.status, from_utf8(&output.stderr).unwrap_or("(Error: Could not fetch Cargo's stderr output)") ))) } Err(e) => Err(io::Error::new(e.kind(), format!("{:?}: {}", e, error))), From 84cf6ad09190cc72a5daf45181812f555162235c Mon Sep 17 00:00:00 2001 From: Cadu Date: Tue, 5 Apr 2022 11:17:39 -0300 Subject: [PATCH 4/4] Using `error` instead of `output.stderr` in failure mode. --- crates/flycheck/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index b01f275cdc..4c84c62016 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -2,7 +2,7 @@ //! another compatible command (f.x. clippy) in a background thread and provide //! LSP diagnostics based on the output of the command. -use std::{fmt, io, process::Command, time::Duration, str::from_utf8}; +use std::{fmt, io, process::Command, time::Duration}; use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; use paths::AbsPathBuf; @@ -330,7 +330,7 @@ impl CargoActor { Ok(output) => { Err(io::Error::new(io::ErrorKind::Other, format!( "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nCargo's stderr output:\n{}", - output.status, from_utf8(&output.stderr).unwrap_or("(Error: Could not fetch Cargo's stderr output)") + output.status, error ))) } Err(e) => Err(io::Error::new(e.kind(), format!("{:?}: {}", e, error))),