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

bool_assert_comparison: assert_eq! with a literal bool #8118

Closed
cemoktra opened this issue Dec 13, 2021 · 2 comments · Fixed by #10218
Closed

bool_assert_comparison: assert_eq! with a literal bool #8118

cemoktra opened this issue Dec 13, 2021 · 2 comments · Fixed by #10218
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 T-macros Type: Issues with macros and macro expansion

Comments

@cemoktra
Copy link

Description

Hi,

i have a macro which generated a function for use in unit tests which is:

assert_eq!($MacroInput, my_struct.macro_input());

Clippy indicates in this case that i should use assert! but this would mean that i have to write an if/else block to handle both cases.
While this makes sense if i have a hardcoded boolean literal, but in this case i have macro generated boolean literals.

Version

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Additional Labels

No response

@xFrednet xFrednet 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 T-macros Type: Issues with macros and macro expansion labels Dec 13, 2021
@giraffate
Copy link
Contributor

Can you provide a minimal reproduction on the playground?

@cemoktra
Copy link
Author

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d1294390d2e6e3e4a416c600ccbcb74b

@giraffate giraffate changed the title assert_eq! with a literal bool bool_assert_comparison : assert_eq! with a literal bool Dec 14, 2021
@giraffate giraffate changed the title bool_assert_comparison : assert_eq! with a literal bool bool_assert_comparison: assert_eq! with a literal bool Dec 14, 2021
@bors bors closed this as completed in e0ee58b Jan 21, 2023
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 T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants