Skip to content

Commit 582bf9a

Browse files
committed
Rename if_then_panic to manual_assert
1 parent b0b76a4 commit 582bf9a

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,6 @@ Released 2018-09-13
27472747
[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
27482748
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
27492749
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
2750-
[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
27512750
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
27522751
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
27532752
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
@@ -2805,6 +2804,7 @@ Released 2018-09-13
28052804
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
28062805
[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
28072806
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
2807+
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
28082808
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
28092809
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
28102810
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ store.register_lints(&[
157157
identity_op::IDENTITY_OP,
158158
if_let_mutex::IF_LET_MUTEX,
159159
if_not_else::IF_NOT_ELSE,
160-
if_then_panic::IF_THEN_PANIC,
161160
if_then_some_else_none::IF_THEN_SOME_ELSE_NONE,
162161
implicit_hasher::IMPLICIT_HASHER,
163162
implicit_return::IMPLICIT_RETURN,
@@ -214,6 +213,7 @@ store.register_lints(&[
214213
loops::WHILE_LET_ON_ITERATOR,
215214
macro_use::MACRO_USE_IMPORTS,
216215
main_recursion::MAIN_RECURSION,
216+
manual_assert::MANUAL_ASSERT,
217217
manual_async_fn::MANUAL_ASYNC_FN,
218218
manual_map::MANUAL_MAP,
219219
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,

clippy_lints/src/lib.register_pedantic.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ mod get_last_with_len;
227227
mod identity_op;
228228
mod if_let_mutex;
229229
mod if_not_else;
230-
mod if_then_panic;
231230
mod if_then_some_else_none;
232231
mod implicit_hasher;
233232
mod implicit_return;
@@ -254,6 +253,7 @@ mod literal_representation;
254253
mod loops;
255254
mod macro_use;
256255
mod main_recursion;
256+
mod manual_assert;
257257
mod manual_async_fn;
258258
mod manual_map;
259259
mod manual_non_exhaustive;
@@ -767,7 +767,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
767767
store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
768768
store.register_late_pass(move || Box::new(feature_name::FeatureName));
769769
store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
770-
store.register_late_pass(move || Box::new(if_then_panic::IfThenPanic));
770+
store.register_late_pass(move || Box::new(manual_assert::ManualAssert));
771771
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
772772
store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send)));
773773
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 8 deletions
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)