Skip to content

clippy-driver passes --sysroot more than once #12201

Closed
@daivinhtran

Description

@daivinhtran

Summary

The Bazel rules set for rust pass the same flags to clippy-driver as it would pass to rustc. This has worked till we hit a corner case (see bazelbuild/rules_rust#2447) where we set both --sysroot flag and SYSROOT env var and the --sysroot flag ends up in a param file that rustc correctly handles.

Reproducer

  1. Create a file @program.params with --sysroot=""
  2. Run SYSROOT="" clippy-driver @program.params

I expected to see the command not to fail because SYSROOT="" clippy-driver --sysroot works fine.

Instead, it fails with

error: Option 'sysroot' given more than once

because

let has_sysroot_arg = arg_value(&orig_args, "--sysroot", |_| true).is_some();

checks whether the args includes --sysroot but doesn't check whether @program.params includes --sysroot.

Version

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: aarch64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions