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

must_use lint only triggered when code is modified on clean build #5094

Closed
lopopolo opened this issue Jan 25, 2020 · 7 comments
Closed

must_use lint only triggered when code is modified on clean build #5094

lopopolo opened this issue Jan 25, 2020 · 7 comments

Comments

@lopopolo
Copy link

In my project with deny(clippy::pedantic), I get these warnings for code that aleady existed, triggered by writing to the file:

$ cargo clippy -- -D warnings
warning: couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
warning: set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable
    Checking artichoke-backend v0.1.0 (/Users/lopopolo/dev/artichoke/artichoke/artichoke-backend)
error: this method could have a `#[must_use]` attribute
   --> artichoke-backend/src/sys/mod.rs:154:5
    |
154 |     fn info(&self) -> String {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn info(&self) -> String`
    |
note: lint level defined here
   --> artichoke-backend/src/lib.rs:2:9
    |
2   | #![deny(clippy::pedantic)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[deny(clippy::must_use_candidate)]` implied by `#[deny(clippy::pedantic)]`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate

error: this method could have a `#[must_use]` attribute
   --> artichoke-backend/src/sys/mod.rs:158:5
    |
158 |     fn debug(&self) -> String {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn debug(&self) -> String`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate

error: this method could have a `#[must_use]` attribute
   --> artichoke-backend/src/sys/mod.rs:162:5
    |
162 |     fn version(&self) -> String {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn version(&self) -> String`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate

error: this method could have a `#[must_use]` attribute
   --> artichoke-backend/src/sys/mod.rs:168:5
    |
168 |     fn info(&self) -> String {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn info(&self) -> String`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate

error: this method could have a `#[must_use]` attribute
   --> artichoke-backend/src/sys/mod.rs:172:5
    |
172 |     fn debug(&self) -> String {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn debug(&self) -> String`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate

error: aborting due to 5 previous errors

The following warnings were emitted during compilation:

warning: couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
warning: set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable

error: could not compile `artichoke-backend`.

To learn more, run the command again with --verbose.

On any write to artichoke-backend/src/sys/mod.rs in vim, subsequent runs of clippy produce no errors.

I added #[must_use] to every function Clippy asked me to when I upgraded to Rust 1.40.0, but this file generated no complaints, even in CI, until I modified it to add some additional impls of the trait these methods are in when writing a recent commit.

Any idea what is going on here?

lopopolo added a commit to artichoke/artichoke that referenced this issue Jan 25, 2020
@flip1995
Copy link
Member

flip1995 commented Jan 25, 2020

Can you try if the same thing happens with cargo clippy-preview -Zunstable-options -- -Wclippy::pedantic? If that's the case it will be fixed by #3837.

@lopopolo
Copy link
Author

with cargo +nightly clippy-preview -Zunstable-options -- -Wclippy::pedantic on cargo 1.42.0-nightly (f6449ba23 2020-01-21) the lint doesn't trigger at all, even after writing the file like before.

@flip1995
Copy link
Member

When I checkout artichoke/artichoke@1c7de40 and run cargo +stable clippy -- -D warnings, I get the error messages of the must_use lint. At least on a clean build.

@flip1995
Copy link
Member

With the nightly compiler/clippy, this lint won't be emitted on these functions. It seems that the lint has changed somehow since 1.40.0.

@lopopolo
Copy link
Author

It seems that this is not scoped to must_use_candidate. Clippy does not run on incremental builds sometimes.

I got this build failure in CI after a clean incremental run on my local box.

https://circleci.com/gh/artichoke/artichoke/5748?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

$ cargo clippy -- --version
clippy 0.0.212 (c8e3cfbd 2019-10-28)
$ cargo --version
cargo 1.40.0 (bc8e4c8be 2019-11-22)
$ rustc --version
rustc 1.40.0 (73528e339 2019-12-16)

@flip1995
Copy link
Member

Clippy does not run on incremental builds sometimes.

Oh yeah, we know this. This will be fixed with #3837. If you want clippy to run reliably on incremental builds you can use cargo +nightly clippy-preview -Zunstable-options, until #3837 is finished.

@flip1995
Copy link
Member

See also #2604

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

No branches or pull requests

2 participants