Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6b4c0e0

Browse files
committed
Further simplifications
1 parent 786ef83 commit 6b4c0e0

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/tools/rust-analyzer/editors/code/src/bootstrap.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,12 @@ function orderFromPath(
153153
path: string,
154154
raVersionResolver: (path: string) => string | undefined,
155155
): string {
156-
const capture = path.match(/^.*\/toolchains\/(.*)\/bin\/rust-analyzer$/);
157-
if (capture?.length === 2) {
158-
const toolchain = capture[1]!;
159-
// It is a semver, so we must resolve Rust Analyzer's version.
160-
const raVersion = raVersionResolver(path);
161-
const raDate = raVersion?.match(/^rust-analyzer .*\(.* (\d{4}-\d{2}-\d{2})\)$/);
162-
if (raDate?.length === 2) {
163-
const precedence = toolchain.startsWith("nightly-") ? "/0" : "/1";
164-
return "0-" + raDate[1] + precedence;
165-
} else {
166-
return "2";
167-
}
156+
// It is a semver, so we must resolve Rust Analyzer's version.
157+
const raVersion = raVersionResolver(path);
158+
const raDate = raVersion?.match(/^rust-analyzer .*\(.* (\d{4}-\d{2}-\d{2})\)$/);
159+
if (raDate?.length === 2) {
160+
const precedence = path.includes("nightly-") ? "0" : "1";
161+
return precedence + "-" + raDate[1];
168162
} else {
169163
return "2";
170164
}

src/tools/rust-analyzer/editors/code/tests/unit/bootstrap.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function getTests(ctx: Context) {
1616
return "rust-analyzer 1.67.0-nightly (b7bc90fe 2022-11-21)";
1717
},
1818
),
19-
"0-2022-11-21/0",
19+
"0-2022-11-21",
2020
);
2121
});
2222

@@ -32,7 +32,7 @@ export async function getTests(ctx: Context) {
3232
return "rust-analyzer 1.72.1 (d5c2e9c3 2023-09-13)";
3333
},
3434
),
35-
"0-2023-09-13/1",
35+
"1-2023-09-13",
3636
);
3737
});
3838

@@ -60,14 +60,14 @@ export async function getTests(ctx: Context) {
6060
return "rust-analyzer 1.79.0 (129f3b99 2024-06-10)";
6161
},
6262
),
63-
"0-2024-06-10/1",
63+
"1-2024-06-10",
6464
);
6565
});
6666

6767
suite.addTest("Order with invalid path to RA", async () => {
6868
assert.deepStrictEqual(
6969
_private.orderFromPath("some-weird-path", function () {
70-
assert.fail("Shouldn't get here.");
70+
return undefined;
7171
}),
7272
"2",
7373
);

0 commit comments

Comments
 (0)