mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
af43950143
Macro check for assertion_on_constants lint The `assertion_on_constants` lint currently has following output for this code [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6f2c9df6fc50baf847212d3b5136ee97): ```rust macro_rules! assert_const { ($len:expr) => { assert!($len > 0); } } fn main() { assert_const!(3); assert_const!(-1); } ``` ``` warning: assert!(const: true) will be optimized out by the compiler --> src/main.rs:3:9 | 3 | assert!($len > 0); | ^^^^^^^^^^^^^^^^^^ ... 8 | assert_const!(3); | ---------------- in this macro invocation | = note: #[warn(clippy::assertions_on_constants)] on by default = help: remove it = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants warning: assert!(const: false) should probably be replaced --> src/main.rs:3:9 | 3 | assert!($len > 0); | ^^^^^^^^^^^^^^^^^^ ... 9 | assert_const!(-1); | ----------------- in this macro invocation | = help: use panic!() or unreachable!() = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants ``` This is contradictory. This lint should not trigger if the `assert!` is in a macro itself. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |