aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-04 23:35:13 +0100
committerGitHub <[email protected]>2021-04-04 23:35:13 +0100
commit4be4d29853633a0e51b9707edc58c556a99a7249 (patch)
treeafb5fd141bf9525f029cacb99a9fbb7225921daf
parentd3dfa18071cdccd2757db7eeff2ffec21b25ffd4 (diff)
parentd3b804d11d554e6d4e4ccbad92add86e093b4bdb (diff)
Merge #8332
8332: Error when `rustfmt` component is unavailable r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8331 When the toolchain has no installable rustfmt component, running `rustfmt` complains with ``` error: the 'rustfmt' component which provides the command 'rustfmt' is not available for the 'nightly-2021-04-04-x86_64-unknown-linux-gnu' toolchain ``` Check for occurrence of "not available" in addition to the existing "not installed" to detect this case and report a user-visible error. rustfmt and/or rustup should *really* be changed to not use the same exit status here bors r+ Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r--crates/rust-analyzer/src/handlers.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 53d29ddfc..e8f9f2179 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -928,7 +928,10 @@ pub(crate) fn handle_formatting(
928 928
929 if !output.status.success() { 929 if !output.status.success() {
930 match output.status.code() { 930 match output.status.code() {
931 Some(1) if !captured_stderr.contains("not installed") => { 931 Some(1)
932 if !captured_stderr.contains("not installed")
933 && !captured_stderr.contains("not available") =>
934 {
932 // While `rustfmt` doesn't have a specific exit code for parse errors this is the 935 // While `rustfmt` doesn't have a specific exit code for parse errors this is the
933 // likely cause exiting with 1. Most Language Servers swallow parse errors on 936 // likely cause exiting with 1. Most Language Servers swallow parse errors on
934 // formatting because otherwise an error is surfaced to the user on top of the 937 // formatting because otherwise an error is surfaced to the user on top of the