rust-lang/rust-clippy

Manual assert_eq! (enhance `if_then_panic`)

Open

#7,716 opened on Sep 24, 2021

View on GitHub
 (7 comments) (0 reactions) (1 assignee)Rust (10,406 stars) (1,391 forks)batch import
C-enhancementgood first issue

Description

We just added if_then_panic, but then I realized there's a possible enhancement for assert_eq!/assert_ne!:

// before
if a != b {
    panic!("hi");
}
// after
assert_eq!(a, b, "hi");

I think a rename to manual_assert would be best. But we could also keep the current name (it still kinda makes sense) or create a new lint for this case.

Contributor guide

Manual assert_eq! (enhance `if_then_panic`) · rust-lang/rust-clippy#7716 | Good First Issue