Skip to content

Commit 4be4d29

Browse files
Merge #8332
8332: Error when `rustfmt` component is unavailable r=jonas-schievink a=jonas-schievink Fixes #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]>
2 parents d3dfa18 + d3b804d commit 4be4d29

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,10 @@ pub(crate) fn handle_formatting(
928928

929929
if !output.status.success() {
930930
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+
{
932935
// While `rustfmt` doesn't have a specific exit code for parse errors this is the
933936
// likely cause exiting with 1. Most Language Servers swallow parse errors on
934937
// formatting because otherwise an error is surfaced to the user on top of the

0 commit comments

Comments
 (0)