Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy caches failures caused by invalid command line options o_O #12623

Closed
pacak opened this issue Apr 2, 2024 · 1 comment · Fixed by #13468
Closed

clippy caches failures caused by invalid command line options o_O #12623

pacak opened this issue Apr 2, 2024 · 1 comment · Fixed by #13468
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@pacak
Copy link
Contributor

pacak commented Apr 2, 2024

Summary

I'm pretty sure it's not supposed to do that...

Btw, I've seen similar behavior to other tools (rustc, rust-analyzer), but managed to make a small reproducer only for clippy.

Reproducer

Type all of those

cargo new --lib demo && cd demo
cargo  clippy
mkdir .cargo        
                    
cat >> .cargo/config.toml << __EOF__
[target.'cfg(target_arch="x86_64")']
rustflags = "-Ctarget-feature=+fma,+avx2"
__EOF__

cargo clippy -- -W clippy::all -p demo
cargo clippy

Final call to clippy fails with no options

% cargo clippy
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/pacak/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/clippy-driver /home/pacak/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -C link-arg=-fuse-ld=mold -C target-feature=+fma,+avx2 -Ctarget-feature=+fma,+avx2 --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 1)
  --- stderr
  error: Unrecognized option: 'p'

Version

rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-unknown-linux-gnu
release: 1.77.1
LLVM version: 17.0.6


Or nightly as of today

Additional Labels

No response

@Alexendoo
Copy link
Member

alternative:

cargo new --lib demo && cd demo

cargo check
cargo clippy -- -x
cargo clippy
  • The first clippy/check creates the target dir including target/.rustc_info.json, it seems failures aren't recorded in .rustc_info.json if it doesn't exist yet
  • In the second command cargo records the result of the target info acquisition under a different hash
  • The third command uses the same hash to retrieve the previously failed result

The issue being CLIPPY_ARGS is not taken into account when creating the hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants