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::missing-assert-message gives false positive #13490

Open
insideoutclub opened this issue Oct 2, 2024 · 0 comments
Open

clippy::missing-assert-message gives false positive #13490

insideoutclub opened this issue Oct 2, 2024 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@insideoutclub
Copy link

Summary

This lint shows up even when I add as message as a second parameter to the assert! macro.

Lint Name

missing-assert-message

Reproducer

I tried this code:

pub struct Service {
    ready: bool,
}

pub fn call(service: Service) {
    assert!(service.ready, "`service.poll_ready()` must be called first to ensure that service is ready to receive requests");
}

I saw this happen:

C:\Users\sandersd\Exercism\rust\poker\src>cargo clippy -- -Dclippy::missing_assert_message
    Checking poker v1.1.0 (C:\Users\sandersd\Exercism\rust\poker)
error: assert without any message
 --> src\lib.rs:6:5
  |
6 |     assert!(service.ready, "`service.poll_ready()` must be called first to ensure that service is ready to receive requests...
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: consider describing why the failing assert is problematic
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_assert_message
  = note: requested on the command line with `-D clippy::missing-assert-message`

error: could not compile `poker` (lib) due to 1 previous error```

I expected to see this happen:

C:\Users\sandersd\Exercism\rust\poker\src>cargo clippy -- -Dclippy::missing_assert_message
    Checking poker v1.1.0 (C:\Users\sandersd\Exercism\rust\poker)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.50s

### Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-pc-windows-msvc
release: 1.81.0
LLVM version: 18.1.7

### Additional Labels

_No response_
@insideoutclub insideoutclub added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Oct 2, 2024
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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

1 participant