-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Description
This is not a pressing issue yet, but it appears in a nightly version of clippy, so you might be interested in addressing the lint ahead of time.
I'm using this simple snippet:
use approx::assert_relative_eq;
fn main() {
assert_relative_eq!(1.0, 2.0);
}
When running cargo +nightly clippy
, I get:
warning: only a `panic!` in `if`-then statement
--> src\main.rs:4:2
|
4 | assert_relative_eq!(1.0, 2.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::if_then_panic)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
= note: this warning originates in the macro `__assert_approx` (in Nightly builds, run with -Z macro-backtrace for more info)
This occurred in the CI of the downstream project godot-rust, which treats clippy warnings as errors (the nightly workflow still passes though).
It has to do with how the __assert_approx
macro is implemented.
Basically, the lint tries to detect the structure
if !cond { panic!(msg); }
and transform it into
assert!(cond, msg);
This would be one option to fix it, another would be to #[allow(clippy::if_then_panic)]
the relevant statements.
I'm using rustc 1.57.0-nightly (5b210643e 2021-10-11)
.
EFanZh
Metadata
Metadata
Assignees
Labels
No labels