diff --git a/examples/hello_lib/BUILD b/examples/hello_lib/BUILD index 758eee9184..177beafdc7 100644 --- a/examples/hello_lib/BUILD +++ b/examples/hello_lib/BUILD @@ -45,6 +45,26 @@ rust_library( crate_type = "staticlib", ) +# Regression test for #368: static lib with dependencies fail. +rust_library( + name = "hello_test_staticlib", + srcs = [ + "tests/greeting.rs", + ], + deps = [":hello_lib"], + crate_type = "staticlib", +) + +# Regression test for #368: cdylib lib with dependencies fail. +rust_library( + name = "hello_test_cdylib", + srcs = [ + "tests/greeting.rs", + ], + deps = [":hello_lib"], + crate_type = "cdylib", +) + rust_test( name = "hello_lib_test", crate = ":hello_lib", diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index f41e63e2c2..6d8654fb46 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -548,7 +548,7 @@ 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] + cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep] cc_infos.append(CcInfo(linking_context = linking_context)) return [cc_common.merge_cc_infos(cc_infos = cc_infos)]