Skip to content

Commit 022146d

Browse files
committed
Rename if_then_panic to manual_assert
1 parent d8fcfd7 commit 022146d

8 files changed

+21
-21
lines changed

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Current beta, release 2021-12-02
3434
[#7610](https://github.com/rust-lang/rust-clippy/pull/7610)
3535
* [`same_name_method`]
3636
[#7653](https://github.com/rust-lang/rust-clippy/pull/7653)
37-
* [`if_then_panic`] [#7669](https://github.com/rust-lang/rust-clippy/pull/7669)
37+
* [`manual_assert`] [#7669](https://github.com/rust-lang/rust-clippy/pull/7669)
3838
* [`non_send_fields_in_send_ty`]
3939
[#7709](https://github.com/rust-lang/rust-clippy/pull/7709)
4040
* [`equatable_if_let`]
@@ -139,7 +139,7 @@ Current beta, release 2021-12-02
139139
`rsplitn` is used [#7663](https://github.com/rust-lang/rust-clippy/pull/7663)
140140
* [`while_let_on_iterator`]: Produce correct suggestion when using `&mut`
141141
[#7690](https://github.com/rust-lang/rust-clippy/pull/7690)
142-
* [`if_then_panic`]: No better handles complex conditions
142+
* [`manual_assert`]: No better handles complex conditions
143143
[#7741](https://github.com/rust-lang/rust-clippy/pull/7741)
144144
* Correctly handle signs in exponents in numeric literals lints
145145
[#7747](https://github.com/rust-lang/rust-clippy/pull/7747)
@@ -2895,7 +2895,6 @@ Released 2018-09-13
28952895
[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
28962896
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
28972897
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
2898-
[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
28992898
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
29002899
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
29012900
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
@@ -2953,6 +2952,7 @@ Released 2018-09-13
29532952
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
29542953
[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
29552954
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
2955+
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
29562956
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
29572957
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
29582958
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map

clippy_lints/src/lib.register_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ store.register_lints(&[
159159
identity_op::IDENTITY_OP,
160160
if_let_mutex::IF_LET_MUTEX,
161161
if_not_else::IF_NOT_ELSE,
162-
if_then_panic::IF_THEN_PANIC,
163162
if_then_some_else_none::IF_THEN_SOME_ELSE_NONE,
164163
implicit_hasher::IMPLICIT_HASHER,
165164
implicit_return::IMPLICIT_RETURN,
@@ -216,6 +215,7 @@ store.register_lints(&[
216215
loops::WHILE_LET_ON_ITERATOR,
217216
macro_use::MACRO_USE_IMPORTS,
218217
main_recursion::MAIN_RECURSION,
218+
manual_assert::MANUAL_ASSERT,
219219
manual_async_fn::MANUAL_ASYNC_FN,
220220
manual_map::MANUAL_MAP,
221221
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,

clippy_lints/src/lib.register_pedantic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
3434
LintId::of(functions::MUST_USE_CANDIDATE),
3535
LintId::of(functions::TOO_MANY_LINES),
3636
LintId::of(if_not_else::IF_NOT_ELSE),
37-
LintId::of(if_then_panic::IF_THEN_PANIC),
3837
LintId::of(implicit_hasher::IMPLICIT_HASHER),
3938
LintId::of(implicit_saturating_sub::IMPLICIT_SATURATING_SUB),
4039
LintId::of(inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR),
@@ -49,6 +48,7 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
4948
LintId::of(loops::EXPLICIT_INTO_ITER_LOOP),
5049
LintId::of(loops::EXPLICIT_ITER_LOOP),
5150
LintId::of(macro_use::MACRO_USE_IMPORTS),
51+
LintId::of(manual_assert::MANUAL_ASSERT),
5252
LintId::of(manual_ok_or::MANUAL_OK_OR),
5353
LintId::of(match_on_vec_items::MATCH_ON_VEC_ITEMS),
5454
LintId::of(matches::MATCH_BOOL),

clippy_lints/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ mod get_last_with_len;
228228
mod identity_op;
229229
mod if_let_mutex;
230230
mod if_not_else;
231-
mod if_then_panic;
232231
mod if_then_some_else_none;
233232
mod implicit_hasher;
234233
mod implicit_return;
@@ -255,6 +254,7 @@ mod literal_representation;
255254
mod loops;
256255
mod macro_use;
257256
mod main_recursion;
257+
mod manual_assert;
258258
mod manual_async_fn;
259259
mod manual_map;
260260
mod manual_non_exhaustive;
@@ -772,7 +772,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
772772
store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
773773
store.register_late_pass(move || Box::new(feature_name::FeatureName));
774774
store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
775-
store.register_late_pass(move || Box::new(if_then_panic::IfThenPanic));
775+
store.register_late_pass(move || Box::new(manual_assert::ManualAssert));
776776
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
777777
store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send)));
778778
store.register_late_pass(move || Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::default()));

clippy_lints/src/if_then_panic.rs renamed to clippy_lints/src/manual_assert.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ declare_clippy_lint! {
2626
/// let sad_people: Vec<&str> = vec![];
2727
/// assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);
2828
/// ```
29-
pub IF_THEN_PANIC,
29+
pub MANUAL_ASSERT,
3030
pedantic,
3131
"`panic!` and only a `panic!` in `if`-then statement"
3232
}
3333

34-
declare_lint_pass!(IfThenPanic => [IF_THEN_PANIC]);
34+
declare_lint_pass!(ManualAssert => [MANUAL_ASSERT]);
3535

36-
impl LateLintPass<'_> for IfThenPanic {
36+
impl LateLintPass<'_> for ManualAssert {
3737
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
3838
if_chain! {
3939
if let Expr {
@@ -86,7 +86,7 @@ impl LateLintPass<'_> for IfThenPanic {
8686

8787
span_lint_and_sugg(
8888
cx,
89-
IF_THEN_PANIC,
89+
MANUAL_ASSERT,
9090
expr.span,
9191
"only a `panic!` in `if`-then statement",
9292
"try",

tests/ui/if_then_panic.fixed renamed to tests/ui/manual_assert.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::if_then_panic)]
2+
#![warn(clippy::manual_assert)]
33

44
fn main() {
55
let a = vec![1, 2, 3];

tests/ui/if_then_panic.rs renamed to tests/ui/manual_assert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::if_then_panic)]
2+
#![warn(clippy::manual_assert)]
33

44
fn main() {
55
let a = vec![1, 2, 3];

tests/ui/if_then_panic.stderr renamed to tests/ui/manual_assert.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
error: only a `panic!` in `if`-then statement
2-
--> $DIR/if_then_panic.rs:19:5
2+
--> $DIR/manual_assert.rs:19:5
33
|
44
LL | / if !a.is_empty() {
55
LL | | panic!("qaqaq{:?}", a);
66
LL | | }
77
| |_____^ help: try: `assert!(a.is_empty(), "qaqaq{:?}", a);`
88
|
9-
= note: `-D clippy::if-then-panic` implied by `-D warnings`
9+
= note: `-D clippy::manual-assert` implied by `-D warnings`
1010

1111
error: only a `panic!` in `if`-then statement
12-
--> $DIR/if_then_panic.rs:22:5
12+
--> $DIR/manual_assert.rs:22:5
1313
|
1414
LL | / if !a.is_empty() {
1515
LL | | panic!("qwqwq");
1616
LL | | }
1717
| |_____^ help: try: `assert!(a.is_empty(), "qwqwq");`
1818

1919
error: only a `panic!` in `if`-then statement
20-
--> $DIR/if_then_panic.rs:39:5
20+
--> $DIR/manual_assert.rs:39:5
2121
|
2222
LL | / if b.is_empty() {
2323
LL | | panic!("panic1");
2424
LL | | }
2525
| |_____^ help: try: `assert!(!b.is_empty(), "panic1");`
2626

2727
error: only a `panic!` in `if`-then statement
28-
--> $DIR/if_then_panic.rs:42:5
28+
--> $DIR/manual_assert.rs:42:5
2929
|
3030
LL | / if b.is_empty() && a.is_empty() {
3131
LL | | panic!("panic2");
3232
LL | | }
3333
| |_____^ help: try: `assert!(!(b.is_empty() && a.is_empty()), "panic2");`
3434

3535
error: only a `panic!` in `if`-then statement
36-
--> $DIR/if_then_panic.rs:45:5
36+
--> $DIR/manual_assert.rs:45:5
3737
|
3838
LL | / if a.is_empty() && !b.is_empty() {
3939
LL | | panic!("panic3");
4040
LL | | }
4141
| |_____^ help: try: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");`
4242

4343
error: only a `panic!` in `if`-then statement
44-
--> $DIR/if_then_panic.rs:48:5
44+
--> $DIR/manual_assert.rs:48:5
4545
|
4646
LL | / if b.is_empty() || a.is_empty() {
4747
LL | | panic!("panic4");
4848
LL | | }
4949
| |_____^ help: try: `assert!(!(b.is_empty() || a.is_empty()), "panic4");`
5050

5151
error: only a `panic!` in `if`-then statement
52-
--> $DIR/if_then_panic.rs:51:5
52+
--> $DIR/manual_assert.rs:51:5
5353
|
5454
LL | / if a.is_empty() || !b.is_empty() {
5555
LL | | panic!("panic5");

0 commit comments

Comments
 (0)