Skip to content

Commit

Permalink
Fix rustfmt toolchains when consuming rules_rust with bzlmod. (#2410)
Browse files Browse the repository at this point in the history
Fixes #2260
  • Loading branch information
jondo2010 authored Jan 12, 2024
1 parent caa3959 commit abf2ae9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/bzlmod/hello_world/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ build_test(
"@rules_rust//tools/rust_analyzer:gen_rust_project",
],
)

build_test(
name = "rust_fmt",
targets = [
"@rules_rust//:rustfmt",
],
)
6 changes: 6 additions & 0 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ def rust_register_toolchains(
target_compatible_with_by_toolchain[toolchain.name] = triple_to_constraint_set(toolchain.target_triple)
toolchain_types[toolchain.name] = "@rules_rust//rust:toolchain"

toolchain_names.append(rustfmt_repo_name)
toolchain_labels[rustfmt_repo_name] = "@{}_tools//:rustfmt_toolchain".format(rustfmt_repo_name)
exec_compatible_with_by_toolchain[rustfmt_repo_name] = triple_to_constraint_set(exec_triple)
target_compatible_with_by_toolchain[rustfmt_repo_name] = []
toolchain_types[rustfmt_repo_name] = "@rules_rust//rust/rustfmt:toolchain_type"

toolchain_repository_hub(
name = "rust_toolchains",
toolchain_names = toolchain_names,
Expand Down

0 comments on commit abf2ae9

Please sign in to comment.