Skip to content

Commit a95e5a2

Browse files
fix(rust): support not installed toolchain
resolves #6645
1 parent 22a3e9e commit a95e5a2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/segments/rust.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func (r *Rust) Enabled() bool {
1414
{
1515
executable: "rustc",
1616
args: []string{"--version"},
17-
regex: `rustc (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))(-(?P<prerelease>[a-z]+))?)(( \((?P<buildmetadata>[0-9a-f]+ [0-9]+-[0-9]+-[0-9]+)\))?)`,
17+
regex: `(rust version|rustc) (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))(-(?P<prerelease>[a-z]+))?)(( \((?P<buildmetadata>[0-9a-f]+ [0-9]+-[0-9]+-[0-9]+)\))?)`, //nolint:lll
1818
},
1919
}
2020

src/segments/rust_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ func TestRust(t *testing.T) {
1616
{Case: "Rust 1.64.0", ExpectedString: "1.64.0", Version: "rustc 1.64.0"},
1717
{Case: "Rust 1.53.0", ExpectedString: "1.53.0", Version: "rustc 1.53.0 (4369396ce 2021-04-27)"},
1818
{Case: "Rust 1.66.0", ExpectedString: "1.66.0-nightly", Version: "rustc 1.66.0-nightly (01af5040f 2022-10-04)"},
19+
{
20+
Case: "Toolchain not installed",
21+
ExpectedString: "1.81.0",
22+
Version: ` info: syncing channel updates for '1.81.0-x86_64-pc-windows-msvc'
23+
info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04)
24+
info: downloading component 'cargo'
25+
info: downloading component 'clippy'
26+
info: downloading component 'rust-analyzer'
27+
info: downloading component 'rust-src'
28+
info: downloading component 'rust-std'
29+
info: downloading component 'rustc'
30+
info: downloading component 'rustfmt'
31+
info: installing component 'cargo'
32+
info: installing component 'clippy'
33+
info: installing component 'rust-analyzer'
34+
info: installing component 'rust-src'
35+
info: installing component 'rust-std'
36+
info: installing component 'rustc'`,
37+
},
1938
}
2039
for _, tc := range cases {
2140
params := &mockedLanguageParams{

0 commit comments

Comments
 (0)