Skip to content

Commit 72b7d5b

Browse files
committed
Fail if both crate and crate_root attrs are specified on rust_test.
1 parent 882bd59 commit 72b7d5b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust/private/rust.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ def _rust_test_impl(ctx):
354354
ctx.label,
355355
))
356356

357+
if ctx.attr.crate and ctx.attr.crate_root:
358+
fail("rust_test.crate and rust_test.crate_root are mutually exclusive. Update {} to use only one of these attributes".format(
359+
ctx.label,
360+
))
361+
357362
if ctx.attr.crate:
358363
# Target is building the crate in `test` config
359364
crate = ctx.attr.crate[rust_common.crate_info] if rust_common.crate_info in ctx.attr.crate else ctx.attr.crate[rust_common.test_crate_info].crate
@@ -386,7 +391,7 @@ def _rust_test_impl(ctx):
386391
# Need to consider all src files together when transforming
387392
srcs = depset(ctx.files.srcs, transitive = [crate.srcs]).to_list()
388393
compile_data = depset(ctx.files.compile_data, transitive = [crate.compile_data]).to_list()
389-
srcs, compile_data, crate_root = transform_sources(ctx, srcs, compile_data, getattr(ctx.file, "crate_root", None))
394+
srcs, compile_data, crate_root = transform_sources(ctx, srcs, compile_data, crate_root=None)
390395

391396
if crate.compile_data_targets:
392397
compile_data_targets = depset(ctx.attr.compile_data, transitive = [crate.compile_data_targets])

0 commit comments

Comments
 (0)