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

Cargo clean --package doesn't clean all targets if package defines features #5375

Closed
davidlattimore opened this issue Apr 17, 2018 · 3 comments · Fixed by #8210
Closed

Cargo clean --package doesn't clean all targets if package defines features #5375

davidlattimore opened this issue Apr 17, 2018 · 3 comments · Fixed by #8210
Labels

Comments

@davidlattimore
Copy link

davidlattimore commented Apr 17, 2018

At least I think that's what's happening.

Setup:

cargo new --lib p1
cd p1
echo '[features]' >>Cargo.toml
echo 'something = []' >>Cargo.toml

Then run:

cargo clean --package p1 && cargo check -v --tests
cargo clean --package p1 && cargo check -v --tests

Expected:
Since we did a cargo clean of package p1 in between runs of cargo check, I'd expect that the second run should invoke rustc.

Actual:
rustc is only invoked the fist time

Notes:
Doing a full clean (without --package) behaves as expected (rustc invoked both times).
If I don't declare any features in Cargo.toml, then it behaves as expected.

This problem is especially evident if there's a warning inside some #[cfg(test)] code. Once you've compiled once, you can't get the warning back without either (a) editing the file or (b) doing a full clean. i.e. cleaning just the local package then doing a new cargo check isn't sufficient.

Tested on:
cargo 1.26.0-nightly (008c369 2018-04-13)

@joelgallant
Copy link
Contributor

joelgallant commented Oct 24, 2018

This problem is especially evident if there's a warning inside some #[cfg(test)] code. Once you've compiled once, you can't get the warning back without either (a) editing the file or (b) doing a full clean. i.e. cleaning just the local package then doing a new cargo check isn't sufficient.

This also applies to linting - my CI runs were spuriously giving lint errors, which I realized was because clippy was not re-running.

@dwijnand
Copy link
Member

@joelgallant By "also applies to linting" I assume you mean clippy linting, which is tracked as rust-lang/rust-clippy#2604.

@dwijnand
Copy link
Member

Perhaps the cause here is the same as described in #3530:

My hypothesis (which @alexcrichton confirmed) is that each generates a distinct fingerprint, and cargo clean -p foo is looking for a version with no arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants