From 5c785eee58d4f9ef360bc37bd0f57c238cb8bbb0 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 30 Sep 2021 00:27:28 -0400 Subject: [PATCH] Ignore if_then_panic clippy lint error: only a `panic!` in `if`-then statement --> serde_derive/src/internals/ctxt.rs:58:9 | 58 | / if !thread::panicking() && self.errors.borrow().is_some() { 59 | | panic!("forgot to check for errors"); 60 | | } | |_________^ help: try: `assert!(!!thread::panicking() && self.errors.borrow().is_some(), "forgot to check for errors");` | note: the lint level is defined here --> serde_derive/src/lib.rs:18:9 | 18 | #![deny(clippy::all, clippy::pedantic)] | ^^^^^^^^^^^ = note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic error: only a `panic!` in `if`-then statement --> serde_test/src/assert.rs:73:5 | 73 | / if ser.remaining() > 0 { 74 | | panic!("{} remaining tokens", ser.remaining()); 75 | | } | |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());` | note: the lint level is defined here --> serde_test/src/lib.rs:149:44 | 149 | #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))] | ^^^^^^ = note: `#[deny(clippy::if_then_panic)]` implied by `#[deny(clippy::all)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic error: only a `panic!` in `if`-then statement --> serde_test/src/assert.rs:126:5 | 126 | / if ser.remaining() > 0 { 127 | | panic!("{} remaining tokens", ser.remaining()); 128 | | } | |_____^ help: try: `assert!(!ser.remaining() > 0, "{} remaining tokens", ser.remaining());` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic error: only a `panic!` in `if`-then statement --> serde_test/src/assert.rs:166:5 | 166 | / if de.remaining() > 0 { 167 | | panic!("{} remaining tokens", de.remaining()); 168 | | } | |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic error: only a `panic!` in `if`-then statement --> serde_test/src/assert.rs:180:5 | 180 | / if de.remaining() > 0 { 181 | | panic!("{} remaining tokens", de.remaining()); 182 | | } | |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic error: only a `panic!` in `if`-then statement --> serde_test/src/assert.rs:220:5 | 220 | / if de.remaining() > 0 { 221 | | panic!("{} remaining tokens", de.remaining()); 222 | | } | |_____^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic error: only a `panic!` in `if`-then statement --> test_suite/tests/test_de.rs:1349:9 | 1349 | / if de.remaining() > 0 { 1350 | | panic!("{} remaining tokens", de.remaining()); 1351 | | } | |_________^ help: try: `assert!(!de.remaining() > 0, "{} remaining tokens", de.remaining());` | = note: `-D clippy::if-then-panic` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic --- serde_derive/src/lib.rs | 1 + serde_derive_internals/lib.rs | 1 + serde_test/src/lib.rs | 1 + test_suite/tests/test_de.rs | 6 +++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/serde_derive/src/lib.rs b/serde_derive/src/lib.rs index 9bf2c364..1773b7a3 100644 --- a/serde_derive/src/lib.rs +++ b/serde_derive/src/lib.rs @@ -24,6 +24,7 @@ // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7575 clippy::collapsible_match, clippy::enum_variant_names, + clippy::if_then_panic, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6797 clippy::manual_map, clippy::match_like_matches_macro, diff --git a/serde_derive_internals/lib.rs b/serde_derive_internals/lib.rs index aa00e3b1..fa51c365 100644 --- a/serde_derive_internals/lib.rs +++ b/serde_derive_internals/lib.rs @@ -6,6 +6,7 @@ clippy::cognitive_complexity, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7575 clippy::collapsible_match, + clippy::if_then_panic, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6797 clippy::manual_map, clippy::missing_panics_doc, diff --git a/serde_test/src/lib.rs b/serde_test/src/lib.rs index a443026f..34e2fdd0 100644 --- a/serde_test/src/lib.rs +++ b/serde_test/src/lib.rs @@ -155,6 +155,7 @@ allow( cloned_instead_of_copied, empty_line_after_outer_attr, + if_then_panic, missing_docs_in_private_items, missing_panics_doc, module_name_repetitions, diff --git a/test_suite/tests/test_de.rs b/test_suite/tests/test_de.rs index e1a6ea21..15b5d388 100644 --- a/test_suite/tests/test_de.rs +++ b/test_suite/tests/test_de.rs @@ -1,4 +1,8 @@ -#![allow(clippy::decimal_literal_representation, clippy::unreadable_literal)] +#![allow( + clippy::decimal_literal_representation, + clippy::if_then_panic, + clippy::unreadable_literal +)] #![cfg_attr(feature = "unstable", feature(never_type))] use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};