Re: [PATCH v4 1/2] scripts: generate_rust_analyzer.py: add versioning infrastructure
From: Tamir Duberstein
Date: Thu Mar 19 2026 - 11:06:14 EST
On Tue, 17 Mar 2026 18:29:54 +0900, Jesung Yang <y.j3ms.n@xxxxxxxxx> wrote:
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index b4a55344688d..21832763c5be 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -49,7 +54,19 @@ class CrateWithGenerated(Crate):
> source: Source
>
>
> +class RustProject(TypedDict):
> + crates: List[Crate]
> + sysroot: str
> +
Could we move this type down so it's closer to its site of use? It's ~350 linues down.
> @@ -200,67 +227,70 @@ def generate_crates(
> edition=core_edition,
> )
>
> + def sysroot_deps(*deps: Optional[Dependency]) -> List[Dependency]:
> + return [dep for dep in deps if dep is not None]
> +
> # NB: sysroot crates reexport items from one another so setting up our transitive dependencies
It would be great to avoid having to sprinkle this everywhere, though I admit
it's not immediately obvious to me how to achieve it. Maybe we can live with it
until the MSRV bump. Again, would be great to structure this in a way that
makes that cleanup simple when the time comes.
> @@ -335,12 +370,120 @@ def generate_crates(
> [ ... skip 17 lines ... ]
> + Represents rust-analyzer compatibility baselines. Concrete versions are mapped to the most
> + recent baseline they have reached. Must be in release order.
> + """
> +
> + # v0.3.1877, released on 2024-03-11; shipped with the rustup 1.78 toolchain.
> + DEFAULT = (
There should be a note here explaining that this should be bumped when MSRV is
bumped, and how to obtain the new values that should go here. It's really
important that the string MSRV appears as it's a likely grep target for when
that pointer is updated.
> [ ... skip 40 lines ... ]
> + ),
> + "sysroot": str(sysroot),
> + }
> + else:
> + assert_never(version_info)
> +
The call to generate_crates should probably be below the block that synthesizes RaVersionInfo.
> [ ... skip 24 lines ... ]
> + # `rust-analyzer --version` shows different version string depending on how the binary
> + # is built: it may print either the Rust version or the rust-analyzer version itself.
> + # To distinguish between them, we leverage rust-analyzer's versioning convention.
> + #
> + # See:
> + # - https://github.com/rust-lang/rust-analyzer/blob/fad5c3d2d642/xtask/src/dist.rs#L19-L21
either "a different version string" or "different version strings"
--
Tamir Duberstein <tamird@xxxxxxxxxx>