diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index d71c629dde..0f0efd3898 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -688,8 +688,10 @@ def establish_cc_info(ctx, crate_info, toolchain, cc_toolchain, feature_configur linker_inputs = depset([link_input]), ) - cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep] - cc_infos.append(CcInfo(linking_context = linking_context)) + cc_infos = [ CcInfo(linking_context = linking_context) ] + for dep in ctx.attr.deps: + if CcInfo in dep: + cc_infos.append(dep[CcInfo]) return [cc_common.merge_cc_infos(cc_infos = cc_infos)] diff --git a/test/unit/interleaved_cc_info/interleaved_cc_info_test.bzl b/test/unit/interleaved_cc_info/interleaved_cc_info_test.bzl index 67d37c60d3..324e6e909c 100644 --- a/test/unit/interleaved_cc_info/interleaved_cc_info_test.bzl +++ b/test/unit/interleaved_cc_info/interleaved_cc_info_test.bzl @@ -1,7 +1,7 @@ """Unittests for rust rules.""" load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") -load("//rust:defs.bzl", "rust_common", "rust_library") +load("//rust:defs.bzl", "rust_library") load("@rules_cc//cc:defs.bzl", "cc_library") def _interleaving_cc_link_order_test_impl(ctx): @@ -25,15 +25,7 @@ def _interleaving_cc_link_order_test_impl(ctx): interleaving_cc_link_order_test = analysistest.make(_interleaving_cc_link_order_test_impl) -def _interleaving_rust_link_order_test_impl(ctx): - env = analysistest.begin(ctx) - tut = analysistest.target_under_test(env) - dep_info = tut[rust_common.dep_info] - return analysistest.end(env) - -interleaving_rust_link_order_test = analysistest.make(_interleaving_rust_link_order_test_impl) - -def _interleaving_cc_link_order_test(): +def _interleaving_link_order_test(): rust_library( name = "a", srcs = ["a.rs"], @@ -65,23 +57,17 @@ def _interleaving_cc_link_order_test(): target_under_test = ":a", ) - interleaving_rust_link_order_test( - name = "interleaving_rust_link_order_test", - target_under_test = ":a", - ) - def interleaved_cc_info_test_suite(name): """Entry-point macro called from the BUILD file. Args: name: Name of the macro. """ - _interleaving_cc_link_order_test() + _interleaving_link_order_test() native.test_suite( name = name, tests = [ ":interleaving_cc_link_order_test", - ":interleaving_rust_link_order_test", ], )