Rename if_then_panic to manual_assert

This commit is contained in:
Cameron Steffen 2021-10-12 09:23:05 -05:00
parent d8fcfd7d64
commit 022146d2c3
8 changed files with 21 additions and 21 deletions

View File

@ -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

View File

@ -159,7 +159,6 @@
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 @@
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,

View File

@ -34,7 +34,6 @@
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 @@
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),

View File

@ -228,7 +228,6 @@ macro_rules! declare_clippy_lint {
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 @@ macro_rules! declare_clippy_lint {
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()));

View File

@ -26,14 +26,14 @@
/// 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 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
span_lint_and_sugg(
cx,
IF_THEN_PANIC,
MANUAL_ASSERT,
expr.span,
"only a `panic!` in `if`-then statement",
"try",

View File

@ -1,5 +1,5 @@
// run-rustfix
#![warn(clippy::if_then_panic)]
#![warn(clippy::manual_assert)]
fn main() {
let a = vec![1, 2, 3];

View File

@ -1,5 +1,5 @@
// run-rustfix
#![warn(clippy::if_then_panic)]
#![warn(clippy::manual_assert)]
fn main() {
let a = vec![1, 2, 3];

View File

@ -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");