Skip to content

Commit e1225bf

Browse files
borsflip1995
authored andcommitted
Auto merge of rust-lang#7810 - camsteffen:if-then-panic-pedantic, r=flip1995
Move if_then_panic to pedantic and rename to manual_assert
1 parent b7f3f7f commit e1225bf

14 files changed

+41
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2746,7 +2746,6 @@ Released 2018-09-13
27462746
[`if_let_redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_let_redundant_pattern_matching
27472747
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
27482748
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
2749-
[`if_then_panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
27502749
[`if_then_some_else_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none
27512750
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
27522751
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
@@ -2804,6 +2803,7 @@ Released 2018-09-13
28042803
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
28052804
[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
28062805
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
2806+
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
28072807
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
28082808
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
28092809
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map

clippy_lints/src/lib.register_all.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
7474
LintId::of(get_last_with_len::GET_LAST_WITH_LEN),
7575
LintId::of(identity_op::IDENTITY_OP),
7676
LintId::of(if_let_mutex::IF_LET_MUTEX),
77-
LintId::of(if_then_panic::IF_THEN_PANIC),
7877
LintId::of(indexing_slicing::OUT_OF_BOUNDS_INDEXING),
7978
LintId::of(infinite_iter::INFINITE_ITER),
8079
LintId::of(inherent_to_string::INHERENT_TO_STRING),

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ store.register_lints(&[
156156
identity_op::IDENTITY_OP,
157157
if_let_mutex::IF_LET_MUTEX,
158158
if_not_else::IF_NOT_ELSE,
159-
if_then_panic::IF_THEN_PANIC,
160159
if_then_some_else_none::IF_THEN_SOME_ELSE_NONE,
161160
implicit_hasher::IMPLICIT_HASHER,
162161
implicit_return::IMPLICIT_RETURN,
@@ -213,6 +212,7 @@ store.register_lints(&[
213212
loops::WHILE_LET_ON_ITERATOR,
214213
macro_use::MACRO_USE_IMPORTS,
215214
main_recursion::MAIN_RECURSION,
215+
manual_assert::MANUAL_ASSERT,
216216
manual_async_fn::MANUAL_ASYNC_FN,
217217
manual_map::MANUAL_MAP,
218218
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,

clippy_lints/src/lib.register_pedantic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
4848
LintId::of(loops::EXPLICIT_INTO_ITER_LOOP),
4949
LintId::of(loops::EXPLICIT_ITER_LOOP),
5050
LintId::of(macro_use::MACRO_USE_IMPORTS),
51+
LintId::of(manual_assert::MANUAL_ASSERT),
5152
LintId::of(manual_ok_or::MANUAL_OK_OR),
5253
LintId::of(match_on_vec_items::MATCH_ON_VEC_ITEMS),
5354
LintId::of(matches::MATCH_BOOL),

clippy_lints/src/lib.register_style.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![
2727
LintId::of(functions::DOUBLE_MUST_USE),
2828
LintId::of(functions::MUST_USE_UNIT),
2929
LintId::of(functions::RESULT_UNIT_ERR),
30-
LintId::of(if_then_panic::IF_THEN_PANIC),
3130
LintId::of(inherent_to_string::INHERENT_TO_STRING),
3231
LintId::of(len_zero::COMPARISON_TO_EMPTY),
3332
LintId::of(len_zero::LEN_WITHOUT_IS_EMPTY),

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;
@@ -766,7 +766,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
766766
store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
767767
store.register_late_pass(move || Box::new(feature_name::FeatureName));
768768
store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
769-
store.register_late_pass(move || Box::new(if_then_panic::IfThenPanic));
769+
store.register_late_pass(move || Box::new(manual_assert::ManualAssert));
770770
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
771771
store.register_late_pass(move || Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(enable_raw_pointer_heuristic_for_send)));
772772
}

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

Lines changed: 5 additions & 5 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,
30-
style,
29+
pub MANUAL_ASSERT,
30+
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/fallible_impl_from.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(clippy::fallible_impl_from)]
2-
#![allow(clippy::if_then_panic)]
32

43
// docs example
54
struct Foo(i32);

tests/ui/fallible_impl_from.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: consider implementing `TryFrom` instead
2-
--> $DIR/fallible_impl_from.rs:6:1
2+
--> $DIR/fallible_impl_from.rs:5:1
33
|
44
LL | / impl From<String> for Foo {
55
LL | | fn from(s: String) -> Self {
@@ -15,13 +15,13 @@ LL | #![deny(clippy::fallible_impl_from)]
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1616
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
1717
note: potential failure(s)
18-
--> $DIR/fallible_impl_from.rs:8:13
18+
--> $DIR/fallible_impl_from.rs:7:13
1919
|
2020
LL | Foo(s.parse().unwrap())
2121
| ^^^^^^^^^^^^^^^^^^
2222

2323
error: consider implementing `TryFrom` instead
24-
--> $DIR/fallible_impl_from.rs:27:1
24+
--> $DIR/fallible_impl_from.rs:26:1
2525
|
2626
LL | / impl From<usize> for Invalid {
2727
LL | | fn from(i: usize) -> Invalid {
@@ -34,14 +34,14 @@ LL | | }
3434
|
3535
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
3636
note: potential failure(s)
37-
--> $DIR/fallible_impl_from.rs:30:13
37+
--> $DIR/fallible_impl_from.rs:29:13
3838
|
3939
LL | panic!();
4040
| ^^^^^^^^^
4141
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
4242

4343
error: consider implementing `TryFrom` instead
44-
--> $DIR/fallible_impl_from.rs:36:1
44+
--> $DIR/fallible_impl_from.rs:35:1
4545
|
4646
LL | / impl From<Option<String>> for Invalid {
4747
LL | | fn from(s: Option<String>) -> Invalid {
@@ -54,7 +54,7 @@ LL | | }
5454
|
5555
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
5656
note: potential failure(s)
57-
--> $DIR/fallible_impl_from.rs:38:17
57+
--> $DIR/fallible_impl_from.rs:37:17
5858
|
5959
LL | let s = s.unwrap();
6060
| ^^^^^^^^^^
@@ -68,7 +68,7 @@ LL | panic!("{:?}", s);
6868
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
6969

7070
error: consider implementing `TryFrom` instead
71-
--> $DIR/fallible_impl_from.rs:54:1
71+
--> $DIR/fallible_impl_from.rs:53:1
7272
|
7373
LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
7474
LL | | fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
@@ -81,7 +81,7 @@ LL | | }
8181
|
8282
= help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail
8383
note: potential failure(s)
84-
--> $DIR/fallible_impl_from.rs:56:12
84+
--> $DIR/fallible_impl_from.rs:55:12
8585
|
8686
LL | if s.parse::<u32>().ok().unwrap() != 42 {
8787
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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];

0 commit comments

Comments
 (0)