Skip to content

Commit 713ab24

Browse files
authored
collect_inputs.files: fix docs and and add a check for data (#3657)
No functional changes intended.
1 parent 8da6166 commit 713ab24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rust/private/rustc.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ def collect_inputs(
644644
Args:
645645
ctx (ctx): The rule's context object.
646646
file (struct): A struct containing files defined in label type attributes marked as `allow_single_file`.
647-
files (list): A list of all inputs (`ctx.files`).
647+
files (struct): A struct of all inputs (`ctx.files`). When aspects are involved, the rule context
648+
may not correspond to a rust target, so check that files attributes are present before accessing them.
648649
linkstamps (depset): A depset of CcLinkstamps that need to be compiled and linked into all linked binaries.
649650
toolchain (rust_toolchain): The current `rust_toolchain`.
650651
cc_toolchain (CcToolchainInfo): The current `cc_toolchain`.
@@ -717,7 +718,7 @@ def collect_inputs(
717718

718719
# The old default behavior was to include data files at compile time.
719720
# This flag controls whether to include data files in compile_data.
720-
if not toolchain._incompatible_do_not_include_data_in_compile_data:
721+
if hasattr(files, "data") and not toolchain._incompatible_do_not_include_data_in_compile_data:
721722
nolinkstamp_compile_direct_inputs += files.data
722723

723724
if toolchain.target_json:

0 commit comments

Comments
 (0)