feat(bzlmod): Add rust_toolchain_file attribute for rust.toolchain()#3792
feat(bzlmod): Add rust_toolchain_file attribute for rust.toolchain()#3792Geethree wants to merge 1 commit intobazelbuild:mainfrom
Conversation
Adds support for reading Rust toolchain configuration from a rust-toolchain.toml file, allowing Bazel and cargo/rustup to share the same version specification. Supported fields: - channel: Maps to versions attribute - targets: Merged with extra_target_triples - components: Sets dev_components=True if "rustc-dev" present Supports both single-line and multi-line TOML arrays. Fixes bazelbuild#2753
UebelAndre
left a comment
There was a problem hiding this comment.
Thanks! Have you thought about adding a new extension (toolchain_toml for example)? I'm wondering if it make sense in the context of a toml file to allow for varying rustfmt and rust-analyzer rustc versions, and extra target triples. Plus having attributes which end up doing nothing feels bad to me as it's easy to have side effects in future changes where both are set.
| parse_rust_toolchain_file_test = unittest.make(_parse_rust_toolchain_file_test_impl) | ||
|
|
||
| def rust_toolchain_toml_test_suite(name): | ||
| unittest.suite( |
There was a problem hiding this comment.
While it's a bit more verbose, can you use a native.test_suite? I find it much. more readable than the enumerated tests.
dzbarsky
left a comment
There was a problem hiding this comment.
I think writing toml parsers in starlark is unfortunate. Check out https://github.com/dzbarsky/rules_rs/blob/85dcdb2a275565aa4bfa236ba22303e56c720270/rs/private/toml2json.bzl#L3 for an alternative
Adds support for reading Rust toolchain configuration from a rust-toolchain.toml file, allowing Bazel and cargo/rustup to share the same version specification.
Supported fields:
Supports both single-line and multi-line TOML arrays.
Fixes #2753