From fb25d5679949e26621f43cfbbd7f5864a60e2bd9 Mon Sep 17 00:00:00 2001 From: Matthias Seiffert Date: Thu, 3 Oct 2019 14:35:05 +0200 Subject: [PATCH] Mention asserts in doc for unit_cmp lint --- clippy_lints/src/types.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index a42a50e553a..2b3c02ce74e 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -487,7 +487,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnitValue { } declare_clippy_lint! { - /// **What it does:** Checks for comparisons to unit. + /// **What it does:** Checks for comparisons to unit. This includes all binary + /// comparisons (like `==` and `<`) and asserts. /// /// **Why is this bad?** Unit is always equal to itself, and thus is just a /// clumsily written constant. Mostly this happens when someone accidentally @@ -519,6 +520,20 @@ declare_clippy_lint! { /// baz(); /// } /// ``` + /// + /// For asserts: + /// ```rust + /// # fn foo() {}; + /// # fn bar() {}; + /// assert_eq!({ foo(); }, { bar(); }); + /// ``` + /// will always succeed + /// ```rust + /// # fn foo() {}; + /// # fn bar() {}; + /// assert_ne!({ foo(); }, { bar(); }); + /// ``` + /// will always fail pub UNIT_CMP, correctness, "comparing unit values"