Skip to content

[Bug]: Clippy fails when rust target has generated inputs #786

Description

@purkhusid

What happened?

When a rust_library/rust_binary has a generated input the Clippy aspect in rules_lint fails due to conflicting generated files.

Reproduction can be found here: https://github.com/purkhusid/rules_lint/tree/clippy-repro

I'm going to continue debugging this to find the root cause but just wanted to create the issue in case @blorente might know a obvious fix.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 9.0.0

rules_lint at HEAD

Language(s) and/or frameworks involved:
Rust

How to reproduce

Repro here: https://github.com/purkhusid/rules_lint/tree/clippy-repro
Run cd examples/rust && bazel build //... --@aspect_rules_lint//lint:fix to get the following error:

ERROR: file 'src/ok_binary.rs' is generated by these conflicting actions:
Label: //src:ok_binary_with_generated_inputs
Aspects: [//tools/lint:linters.bzl%clippy], []
RuleClass: rust_binary rule
JavaActionClass: class com.google.devtools.build.lib.analysis.actions.StarlarkAction, class com.google.devtools.build.lib.analysis.actions.SymlinkAction
Configuration: 25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105
Mnemonic: CopyFile, Symlink
IsShareable: true
Action key: 79c0e22133eccc03c26a734724830c24b43bfeed90bf33fd989c0d639a6476d5, c90914cc1e7ea06f84518cf4f179e63dbd20dad9358a550644494828e4a4ed28
Progress message: Copying file src/ok_binary.rs, Creating symlink to source file: src/ok_binary.rs
Action describeKey: Copying file src/ok_binary.rs
  Execution info: no-sandbox=1
  Argument: external/bazel_lib++toolchains+coreutils_linux_amd64/coreutils
  Argument: cp
  Argument: src/ok_binary.rs
  Argument: bazel-out/k8-fastbuild/bin/src/ok_binary.rs
  Output paths mode: OFF
, GUID: 7f4fab4d-d0a7-4f0f-8649-1d0337a21fee
inputPath: null

PrimaryInput: File:[/home/danielp/dannidev/repos/purkhusid/rules_lint/examples/rust[source]]src/ok_binary.rs
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-fastbuild/bin]src/ok_binary.rs
Owner information: SimpleAspectKey{baseConfiguredTargetKey=ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}, aspectDescriptor=//tools/lint:linters.bzl%clippy}, ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}
MandatoryInputs: Attempted action contains artifacts not in previous action (first 5): 
	coreutils
Outputs: are equal
ERROR: file 'src/ok_binary.rs' is generated by these conflicting actions:
Label: //src:ok_binary_with_generated_inputs
Aspects: [//tools/lint:linters.bzl%clippy], []
RuleClass: rust_binary rule
JavaActionClass: class com.google.devtools.build.lib.analysis.actions.StarlarkAction, class com.google.devtools.build.lib.analysis.actions.SymlinkAction
Configuration: 25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105
Mnemonic: CopyFile, Symlink
IsShareable: true
Action key: 79c0e22133eccc03c26a734724830c24b43bfeed90bf33fd989c0d639a6476d5, c90914cc1e7ea06f84518cf4f179e63dbd20dad9358a550644494828e4a4ed28
Progress message: Copying file src/ok_binary.rs, Creating symlink to source file: src/ok_binary.rs
Action describeKey: Copying file src/ok_binary.rs
  Execution info: no-sandbox=1
  Argument: external/bazel_lib++toolchains+coreutils_linux_amd64/coreutils
  Argument: cp
  Argument: src/ok_binary.rs
  Argument: bazel-out/k8-fastbuild/bin/src/ok_binary.rs
  Output paths mode: OFF
, GUID: 7f4fab4d-d0a7-4f0f-8649-1d0337a21fee
inputPath: null

PrimaryInput: File:[/home/danielp/dannidev/repos/purkhusid/rules_lint/examples/rust[source]]src/ok_binary.rs
PrimaryOutput: File:[[<execution_root>]bazel-out/k8-fastbuild/bin]src/ok_binary.rs
Owner information: SimpleAspectKey{baseConfiguredTargetKey=ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}, aspectDescriptor=//tools/lint:linters.bzl%clippy}, ConfiguredTargetKey{label=//src:ok_binary_with_generated_inputs, config=BuildConfigurationKey[25295d47ca4f6ac508b9b60443fee8eb136d08978c375ba0944d73eeaac4c105]}
MandatoryInputs: Attempted action contains artifacts not in previous action (first 5): 
	coreutils
Outputs: are equal

Any other information?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions