Compiler doesn't recognise match_bool linting pragma


I have a piece of code which is doing a match on a bool - I find it more readable.

match is_allowed {
    true => unverified_piece,
    false => original_piece,

When I run clippy on this code, I get a message like

help: consider using an if/else expression: if is_allowed { unverified_piece } else { original_piece }
= note: #[warn(match_bool)] on by default
= help: for further information visit

if I add the pragma #[allow(match_bool)] I get a different message

warning: unknown lint: match_bool
–> src/movements/
| #[allow(match_bool)]
| ^^^^^^^^^^
= note: #[warn(unknown_lints)] on by default

This seems inconsistent which is confusing to me. The only way to get the compiler to stop complaining is to add #[allow(unkown_lints)] above the match bool pragma.

Is this a mismatch between clippy and compiler? Is there a simpler solution that I’ve missed?

Thank you!


Yes, compiler and Clippy have separate ideas of lints. You can make Clippy’s directives optional:

#[cfg_attr(feature = "cargo-clippy", allow(match_bool))]


Would that be something that the clippy or compiler team be interested in aligning between those two ?


In this case, you would probably still want some kind of namespacing so that clippy and rustc warning names are guaranteed to never clash, without cross-project agreement every time a new warning is introduced.


Which is likely coming in the not too distant future.