bazelbuild / bazelbuild/rules_rust

Multiple calls to `toolchain()` fails with bzlmod

Open
#2,420 0 comments 2 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

It's currently not possible to have multiple calls to `toolchain()`, since under the hood it just calls `rust_register_toolchains` and the declared meta-repository names step on each other.

e.g.:
```bzl
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
versions = ["1.75.0"],
)
rust.toolchain(
edition = "2021",
versions = ["1.74.0-dev"],
sha256s = ...
)
```

My use-case is mixing-matching multiple toolchain versions and targets. This is doable without bzlmod by skipping `rust_register_toolchains` and instead calling `rust_repository_set` directly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.