Skip to content

Commit 05a67f6

Browse files
committed
different logic is required to access data in aspect
hasattr(ctx, "rule") to detect if we're running in an aspect doesn't seem to work, so I had to explicitly pass a boolean into construct_arguments() Should fix clippy test in CI.
1 parent 135a65a commit 05a67f6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

rust/private/clippy.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def _clippy_aspect_impl(target, ctx):
9292
build_env_file = build_env_file,
9393
build_flags_files = build_flags_files,
9494
maker_path = clippy_marker.path,
95+
aspect = True,
9596
)
9697

9798
# Deny the default-on clippy warning levels.

rust/private/rustc.bzl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,12 @@ def get_linker_and_args(ctx, cc_toolchain, feature_configuration, rpaths):
311311

312312
return ld, link_args, link_env
313313

314-
def _expand_locations(ctx, env):
314+
def _expand_locations(ctx, env, aspect):
315315
"Expand $(location ...) references in user-provided env vars."
316-
data = getattr(ctx.attr, "data", [])
316+
if aspect:
317+
data = getattr(ctx.rule.attr, "data", [])
318+
else:
319+
data = getattr(ctx.attr, "data", [])
317320
return dict([(k, ctx.expand_location(v, data)) for (k, v) in env.items()])
318321

319322
def _process_build_scripts(
@@ -405,7 +408,8 @@ def construct_arguments(
405408
out_dir,
406409
build_env_file,
407410
build_flags_files,
408-
maker_path = None):
411+
maker_path = None,
412+
aspect = False):
409413
"""Builds an Args object containing common rustc flags
410414
411415
Args:
@@ -545,7 +549,7 @@ def construct_arguments(
545549
env["CARGO_BIN_EXE_" + dep_crate_info.output.basename] = dep_crate_info.output.short_path
546550

547551
# Update environment with user provided variables.
548-
env.update(_expand_locations(ctx, crate_info.rustc_env))
552+
env.update(_expand_locations(ctx, crate_info.rustc_env, aspect))
549553

550554
# This empty value satisfies Clippy, which otherwise complains about the
551555
# sysroot being undefined.

0 commit comments

Comments
 (0)