From 022146d2c3c4e1baa65f19c45205152af1a8b997 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Tue, 12 Oct 2021 09:23:05 -0500 Subject: [PATCH] Rename if_then_panic to manual_assert --- CHANGELOG.md | 6 +++--- clippy_lints/src/lib.register_lints.rs | 2 +- clippy_lints/src/lib.register_pedantic.rs | 2 +- clippy_lints/src/lib.rs | 4 ++-- .../src/{if_then_panic.rs => manual_assert.rs} | 8 ++++---- .../{if_then_panic.fixed => manual_assert.fixed} | 2 +- tests/ui/{if_then_panic.rs => manual_assert.rs} | 2 +- ...if_then_panic.stderr => manual_assert.stderr} | 16 ++++++++-------- 8 files changed, 21 insertions(+), 21 deletions(-) rename clippy_lints/src/{if_then_panic.rs => manual_assert.rs} (96%) rename tests/ui/{if_then_panic.fixed => manual_assert.fixed} (96%) rename tests/ui/{if_then_panic.rs => manual_assert.rs} (97%) rename tests/ui/{if_then_panic.stderr => manual_assert.stderr} (83%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 267bc07d8fa61..c78aa5908de90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ Current beta, release 2021-12-02 [#7610](https://github.com/rust-lang/rust-clippy/pull/7610) * [`same_name_method`] [#7653](https://github.com/rust-lang/rust-clippy/pull/7653) -* [`if_then_panic`] [#7669](https://github.com/rust-lang/rust-clippy/pull/7669) +* [`manual_assert`] [#7669](https://github.com/rust-lang/rust-clippy/pull/7669) * [`non_send_fields_in_send_ty`] [#7709](https://github.com/rust-lang/rust-clippy/pull/7709) * [`equatable_if_let`] @@ -139,7 +139,7 @@ Current beta, release 2021-12-02 `rsplitn` is used [#7663](https://github.com/rust-lang/rust-clippy/pull/7663) * [`while_let_on_iterator`]: Produce correct suggestion when using `&mut` [#7690](https://github.com/rust-lang/rust-clippy/pull/7690) -* [`if_then_panic`]: No better handles complex conditions +* [`manual_assert`]: No better handles complex conditions [#7741](https://github.com/rust-lang/rust-clippy/pull/7741) * Correctly handle signs in exponents in numeric literals lints [#7747](https://github.com/rust-lang/rust-clippy/pull/7747) @@ -2895,7 +2895,6 @@ Released 2018-09-13 [`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching [`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else [`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else -[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic [`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none [`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond [`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone @@ -2953,6 +2952,7 @@ Released 2018-09-13 [`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal [`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports [`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion +[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert [`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn [`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map [`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs index 249bf77a8f288..9b21079157463 100644 --- a/clippy_lints/src/lib.register_lints.rs +++ b/clippy_lints/src/lib.register_lints.rs @@ -159,7 +159,6 @@ store.register_lints(&[ identity_op::IDENTITY_OP, if_let_mutex::IF_LET_MUTEX, if_not_else::IF_NOT_ELSE, - if_then_panic::IF_THEN_PANIC, if_then_some_else_none::IF_THEN_SOME_ELSE_NONE, implicit_hasher::IMPLICIT_HASHER, implicit_return::IMPLICIT_RETURN, @@ -216,6 +215,7 @@ store.register_lints(&[ loops::WHILE_LET_ON_ITERATOR, macro_use::MACRO_USE_IMPORTS, main_recursion::MAIN_RECURSION, + manual_assert::MANUAL_ASSERT, manual_async_fn::MANUAL_ASYNC_FN, manual_map::MANUAL_MAP, manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE, diff --git a/clippy_lints/src/lib.register_pedantic.rs b/clippy_lints/src/lib.register_pedantic.rs index d22b3b31f6da7..63ab7f1ca6f67 100644 --- a/clippy_lints/src/lib.register_pedantic.rs +++ b/clippy_lints/src/lib.register_pedantic.rs @@ -34,7 +34,6 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![ LintId::of(functions::MUST_USE_CANDIDATE), LintId::of(functions::TOO_MANY_LINES), LintId::of(if_not_else::IF_NOT_ELSE), - LintId::of(if_then_panic::IF_THEN_PANIC), LintId::of(implicit_hasher::IMPLICIT_HASHER), LintId::of(implicit_saturating_sub::IMPLICIT_SATURATING_SUB), LintId::of(inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR), @@ -49,6 +48,7 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![ LintId::of(loops::EXPLICIT_INTO_ITER_LOOP), LintId::of(loops::EXPLICIT_ITER_LOOP), LintId::of(macro_use::MACRO_USE_IMPORTS), + LintId::of(manual_assert::MANUAL_ASSERT), LintId::of(manual_ok_or::MANUAL_OK_OR), LintId::of(match_on_vec_items::MATCH_ON_VEC_ITEMS), LintId::of(matches::MATCH_BOOL), diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index fc15c591623e6..fd5f164e7a1bd 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -228,7 +228,6 @@ mod get_last_with_len; mod identity_op; mod if_let_mutex; mod if_not_else; -mod if_then_panic; mod if_then_some_else_none; mod implicit_hasher; mod implicit_return; @@ -255,6 +254,7 @@ mod literal_representation; mod loops; mod macro_use; mod main_recursion; +mod manual_assert; mod manual_async_fn; mod manual_map; mod manual_non_exhaustive; @@ -772,7 +772,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors)); store.register_late_pass(move || Box::new(feature_name::FeatureName)); store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator)); - store.register_late_pass(move || Box::new(if_then_panic::IfThenPanic)); + store.register_late_pass(move || Box::new(manual_assert::ManualAssert)); let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send; store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send))); store.register_late_pass(move || Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::default())); diff --git a/clippy_lints/src/if_then_panic.rs b/clippy_lints/src/manual_assert.rs similarity index 96% rename from clippy_lints/src/if_then_panic.rs rename to clippy_lints/src/manual_assert.rs index 7946c93c6ec65..c639be1bccba4 100644 --- a/clippy_lints/src/if_then_panic.rs +++ b/clippy_lints/src/manual_assert.rs @@ -26,14 +26,14 @@ declare_clippy_lint! { /// let sad_people: Vec<&str> = vec![]; /// assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people); /// ``` - pub IF_THEN_PANIC, + pub MANUAL_ASSERT, pedantic, "`panic!` and only a `panic!` in `if`-then statement" } -declare_lint_pass!(IfThenPanic => [IF_THEN_PANIC]); +declare_lint_pass!(ManualAssert => [MANUAL_ASSERT]); -impl LateLintPass<'_> for IfThenPanic { +impl LateLintPass<'_> for ManualAssert { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { if_chain! { if let Expr { @@ -86,7 +86,7 @@ impl LateLintPass<'_> for IfThenPanic { span_lint_and_sugg( cx, - IF_THEN_PANIC, + MANUAL_ASSERT, expr.span, "only a `panic!` in `if`-then statement", "try", diff --git a/tests/ui/if_then_panic.fixed b/tests/ui/manual_assert.fixed similarity index 96% rename from tests/ui/if_then_panic.fixed rename to tests/ui/manual_assert.fixed index 0998f8ffa9de4..9d461cff68d88 100644 --- a/tests/ui/if_then_panic.fixed +++ b/tests/ui/manual_assert.fixed @@ -1,5 +1,5 @@ // run-rustfix -#![warn(clippy::if_then_panic)] +#![warn(clippy::manual_assert)] fn main() { let a = vec![1, 2, 3]; diff --git a/tests/ui/if_then_panic.rs b/tests/ui/manual_assert.rs similarity index 97% rename from tests/ui/if_then_panic.rs rename to tests/ui/manual_assert.rs index 10433c8d54f2d..6aadff887ca8d 100644 --- a/tests/ui/if_then_panic.rs +++ b/tests/ui/manual_assert.rs @@ -1,5 +1,5 @@ // run-rustfix -#![warn(clippy::if_then_panic)] +#![warn(clippy::manual_assert)] fn main() { let a = vec![1, 2, 3]; diff --git a/tests/ui/if_then_panic.stderr b/tests/ui/manual_assert.stderr similarity index 83% rename from tests/ui/if_then_panic.stderr rename to tests/ui/manual_assert.stderr index 5bb62f8756606..ab2786247b1de 100644 --- a/tests/ui/if_then_panic.stderr +++ b/tests/ui/manual_assert.stderr @@ -1,15 +1,15 @@ error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:19:5 + --> $DIR/manual_assert.rs:19:5 | LL | / if !a.is_empty() { LL | | panic!("qaqaq{:?}", a); LL | | } | |_____^ help: try: `assert!(a.is_empty(), "qaqaq{:?}", a);` | - = note: `-D clippy::if-then-panic` implied by `-D warnings` + = note: `-D clippy::manual-assert` implied by `-D warnings` error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:22:5 + --> $DIR/manual_assert.rs:22:5 | LL | / if !a.is_empty() { LL | | panic!("qwqwq"); @@ -17,7 +17,7 @@ LL | | } | |_____^ help: try: `assert!(a.is_empty(), "qwqwq");` error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:39:5 + --> $DIR/manual_assert.rs:39:5 | LL | / if b.is_empty() { LL | | panic!("panic1"); @@ -25,7 +25,7 @@ LL | | } | |_____^ help: try: `assert!(!b.is_empty(), "panic1");` error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:42:5 + --> $DIR/manual_assert.rs:42:5 | LL | / if b.is_empty() && a.is_empty() { LL | | panic!("panic2"); @@ -33,7 +33,7 @@ LL | | } | |_____^ help: try: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:45:5 + --> $DIR/manual_assert.rs:45:5 | LL | / if a.is_empty() && !b.is_empty() { LL | | panic!("panic3"); @@ -41,7 +41,7 @@ LL | | } | |_____^ help: try: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:48:5 + --> $DIR/manual_assert.rs:48:5 | LL | / if b.is_empty() || a.is_empty() { LL | | panic!("panic4"); @@ -49,7 +49,7 @@ LL | | } | |_____^ help: try: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` error: only a `panic!` in `if`-then statement - --> $DIR/if_then_panic.rs:51:5 + --> $DIR/manual_assert.rs:51:5 | LL | / if a.is_empty() || !b.is_empty() { LL | | panic!("panic5");