-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
A-lints-tableArea: [lints] tableArea: [lints] tableA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Description
Problem
Changing an entry in [workspace.lints.clippy]
or [lints.clippy]
causes cargo build
and cargo check
to recompile the project since the arguments to rustc
change. Ideally [workspace.lints.clippy]
/[lints.clippy]
would only change invocations of cargo clippy
, not all cargo
commands.
Steps
# Create workspace
mkdir reproducer
cd reproducer
cat > Cargo.toml <<EOF
[workspace]
members = []
resolver = "3"
EOF
# Create crate
cargo new --vcs none clippy-rebuilds
# Build to ensure the cache works
echo Fresh build
cargo build --verbose --workspace
echo Cached build
cargo build --verbose --workspace
# Add workspace lints
cat >> Cargo.toml <<EOF
[workspace.lints.clippy]
manual_string_new.level = "warn"
EOF
cat >> clippy-rebuilds/Cargo.toml <<EOF
[lints]
workspace = true
EOF
# Check that the cache fails
echo Build after inheriting lints
cargo build --verbose --workspace
Script output:
❯ bash reproducer.bash
Creating binary (application) `clippy-rebuilds` package
Adding `clippy-rebuilds` as member of workspace at `/tmp/reproducer`
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Fresh build
Compiling clippy-rebuilds v0.1.0 (/tmp/reproducer/clippy-rebuilds)
Running `/home/ubuntu/.local/share/rustup/toolchains/1.88.0-x86_64-unknown-linux-gnu/bin/rustc --crate-name clippy_rebuilds --edition=2024 clippy-rebuilds/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=245 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=85dd4b777fcca6fe -C extra-filename=-5c7e267753dfe137 --out-dir /tmp/reproducer/target/debug/deps -C incremental=/tmp/reproducer/target/debug/incremental -L dependency=/tmp/reproducer/target/debug/deps`
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
Cached build
Fresh clippy-rebuilds v0.1.0 (/tmp/reproducer/clippy-rebuilds)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Build after inheriting lints
Dirty clippy-rebuilds v0.1.0 (/tmp/reproducer/clippy-rebuilds): the profile configuration changed
Compiling clippy-rebuilds v0.1.0 (/tmp/reproducer/clippy-rebuilds)
Running `/home/ubuntu/.local/share/rustup/toolchains/1.88.0-x86_64-unknown-linux-gnu/bin/rustc --crate-name clippy_rebuilds --edition=2024 clippy-rebuilds/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=245 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 '--warn=clippy::manual_string_new' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=85dd4b777fcca6fe -C extra-filename=-5c7e267753dfe137 --out-dir /tmp/reproducer/target/debug/deps -C incremental=/tmp/reproducer/target/debug/incremental -L dependency=/tmp/reproducer/target/debug/deps`
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s
Possible Solution(s)
Filter [lints.*]
through the tool they use, see the comment bellow #15969 (comment)
Notes
Tested with both 1.88.0
and 1.89.0
.
Version
cargo 1.89.0 (c24e10642 2025-06-23)
release: 1.89.0
commit-hash: c24e1064277fe51ab72011e2612e556ac56addf7
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.2 vendored)
libcurl: 8.12.1-DEV (sys:0.4.80+curl-8.12.1 vendored ssl:OpenSSL/3.5.0)
ssl: OpenSSL 3.5.0 8 Apr 2025
os: Ubuntu 22.4.0 (jammy) [64-bit]
Metadata
Metadata
Assignees
Labels
A-lints-tableArea: [lints] tableArea: [lints] tableA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-bugCategory: bugCategory: bugS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.