diff --git a/rust/private/toolchain_utils.bzl b/rust/private/toolchain_utils.bzl index c89a447e11..f92ad9ca76 100644 --- a/rust/private/toolchain_utils.bzl +++ b/rust/private/toolchain_utils.bzl @@ -81,20 +81,11 @@ toolchain_files = rule( def _current_rust_toolchain_impl(ctx): toolchain = ctx.toolchains[str(Label("@rules_rust//rust:toolchain_type"))] - files = [ - toolchain.rustc, - toolchain.rust_doc, - toolchain.cargo, - ] - - if toolchain.rustfmt: - files.append(toolchain.rustfmt) - return [ toolchain, toolchain.make_variables, DefaultInfo( - files = depset(files), + files = toolchain.all_files, ), ] diff --git a/test/toolchain/BUILD.bazel b/test/toolchain/BUILD.bazel index b42717221a..6400af931e 100644 --- a/test/toolchain/BUILD.bazel +++ b/test/toolchain/BUILD.bazel @@ -1,3 +1,19 @@ +load("@bazel_skylib//rules:build_test.bzl", "build_test") load(":toolchain_test.bzl", "toolchain_test_suite") toolchain_test_suite(name = "toolchain_test_suite") + +genrule( + name = "inspect", + outs = ["rustc-cfg"], + # rustc assumes it can read things like librustc_driver in order to run this command. + # This is a test to ensure we supply all of the files rustc needs as part of the current_rust_toolchain. + cmd = "$(RUSTC) --print=cfg > $@", + toolchains = ["@rules_rust//rust/toolchain:current_rust_toolchain"], + tools = ["@rules_rust//rust/toolchain:current_rust_toolchain"], +) + +build_test( + name = "inspect_build_test", + targets = [":inspect"], +)