Skip to content

Commit fb25d56

Browse files
committed
Mention asserts in doc for unit_cmp lint
1 parent 320d17a commit fb25d56

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

clippy_lints/src/types.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnitValue {
487487
}
488488

489489
declare_clippy_lint! {
490-
/// **What it does:** Checks for comparisons to unit.
490+
/// **What it does:** Checks for comparisons to unit. This includes all binary
491+
/// comparisons (like `==` and `<`) and asserts.
491492
///
492493
/// **Why is this bad?** Unit is always equal to itself, and thus is just a
493494
/// clumsily written constant. Mostly this happens when someone accidentally
@@ -519,6 +520,20 @@ declare_clippy_lint! {
519520
/// baz();
520521
/// }
521522
/// ```
523+
///
524+
/// For asserts:
525+
/// ```rust
526+
/// # fn foo() {};
527+
/// # fn bar() {};
528+
/// assert_eq!({ foo(); }, { bar(); });
529+
/// ```
530+
/// will always succeed
531+
/// ```rust
532+
/// # fn foo() {};
533+
/// # fn bar() {};
534+
/// assert_ne!({ foo(); }, { bar(); });
535+
/// ```
536+
/// will always fail
522537
pub UNIT_CMP,
523538
correctness,
524539
"comparing unit values"

0 commit comments

Comments
 (0)