diff --git a/examples/bzlmod/hello_world/BUILD.bazel b/examples/bzlmod/hello_world/BUILD.bazel index f76873467f..00896a7c81 100644 --- a/examples/bzlmod/hello_world/BUILD.bazel +++ b/examples/bzlmod/hello_world/BUILD.bazel @@ -56,3 +56,10 @@ build_test( "@rules_rust//tools/rust_analyzer:gen_rust_project", ], ) + +build_test( + name = "rust_fmt", + targets = [ + "@rules_rust//:rustfmt", + ], +) diff --git a/rust/repositories.bzl b/rust/repositories.bzl index cc88cdbad5..610baa79e3 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -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,