Skip to content

Commit 236d79c

Browse files
committed
Rename overflow_check_conditional to panicking_overflow_checks.
1 parent 4942629 commit 236d79c

9 files changed

+46
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5700,6 +5700,7 @@ Released 2018-09-13
57005700
[`panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic
57015701
[`panic_in_result_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_in_result_fn
57025702
[`panic_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_params
5703+
[`panicking_overflow_checks`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_overflow_checks
57035704
[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
57045705
[`partial_pub_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#partial_pub_fields
57055706
[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,12 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
583583
crate::operators::VERBOSE_BIT_MASK_INFO,
584584
crate::option_env_unwrap::OPTION_ENV_UNWRAP_INFO,
585585
crate::option_if_let_else::OPTION_IF_LET_ELSE_INFO,
586-
crate::overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL_INFO,
587586
crate::panic_in_result_fn::PANIC_IN_RESULT_FN_INFO,
588587
crate::panic_unimplemented::PANIC_INFO,
589588
crate::panic_unimplemented::TODO_INFO,
590589
crate::panic_unimplemented::UNIMPLEMENTED_INFO,
591590
crate::panic_unimplemented::UNREACHABLE_INFO,
591+
crate::panicking_overflow_checks::PANICKING_OVERFLOW_CHECKS_INFO,
592592
crate::partial_pub_fields::PARTIAL_PUB_FIELDS_INFO,
593593
crate::partialeq_ne_impl::PARTIALEQ_NE_IMPL_INFO,
594594
crate::partialeq_to_none::PARTIALEQ_TO_NONE_INFO,

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ mod only_used_in_recursion;
274274
mod operators;
275275
mod option_env_unwrap;
276276
mod option_if_let_else;
277-
mod overflow_check_conditional;
278277
mod panic_in_result_fn;
279278
mod panic_unimplemented;
279+
mod panicking_overflow_checks;
280280
mod partial_pub_fields;
281281
mod partialeq_ne_impl;
282282
mod partialeq_to_none;
@@ -787,7 +787,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
787787
let format_args = format_args_storage.clone();
788788
store.register_late_pass(move |_| Box::new(format::UselessFormat::new(format_args.clone())));
789789
store.register_late_pass(|_| Box::new(swap::Swap));
790-
store.register_late_pass(|_| Box::new(overflow_check_conditional::OverflowCheckConditional));
790+
store.register_late_pass(|_| Box::new(panicking_overflow_checks::PanickingOverflowChecks));
791791
store.register_late_pass(|_| Box::<new_without_default::NewWithoutDefault>::default());
792792
store.register_late_pass(move |_| Box::new(disallowed_names::DisallowedNames::new(disallowed_names)));
793793
store.register_late_pass(move |_| {

clippy_lints/src/overflow_check_conditional.rs renamed to clippy_lints/src/panicking_overflow_checks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ declare_clippy_lint! {
2121
/// a + b < a;
2222
/// ```
2323
#[clippy::version = "pre 1.29.0"]
24-
pub OVERFLOW_CHECK_CONDITIONAL,
24+
pub PANICKING_OVERFLOW_CHECKS,
2525
complexity,
2626
"overflow checks inspired by C which are likely to panic"
2727
}
2828

29-
declare_lint_pass!(OverflowCheckConditional => [OVERFLOW_CHECK_CONDITIONAL]);
29+
declare_lint_pass!(PanickingOverflowChecks => [PANICKING_OVERFLOW_CHECKS]);
3030

31-
impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
31+
impl<'tcx> LateLintPass<'tcx> for PanickingOverflowChecks {
3232
// a + b < a, a > a + b, a < a - b, a - b > a
3333
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
3434
if let ExprKind::Binary(op, lhs, rhs) = expr.kind
@@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for OverflowCheckConditional {
5959
{
6060
span_lint(
6161
cx,
62-
OVERFLOW_CHECK_CONDITIONAL,
62+
PANICKING_OVERFLOW_CHECKS,
6363
expr.span,
6464
"you are trying to use classic C overflow conditions that will fail in Rust",
6565
);

clippy_lints/src/renamed_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
2626
("clippy::option_map_unwrap_or", "clippy::map_unwrap_or"),
2727
("clippy::option_map_unwrap_or_else", "clippy::map_unwrap_or"),
2828
("clippy::option_unwrap_used", "clippy::unwrap_used"),
29+
("clippy::overflow_check_conditional", "clippy::panicking_overflow_checks"),
2930
("clippy::ref_in_deref", "clippy::needless_borrow"),
3031
("clippy::result_expect_used", "clippy::expect_used"),
3132
("clippy::result_map_unwrap_or_else", "clippy::map_unwrap_or"),

tests/ui/overflow_check_conditional.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/ui/panicking_overflow_checks.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![warn(clippy::panicking_overflow_checks)]
2+
#![allow(clippy::needless_if)]
3+
4+
fn test(a: u32, b: u32, c: u32) {
5+
if a + b < a {} //~ panicking_overflow_checks
6+
if a > a + b {} //~ panicking_overflow_checks
7+
if a + b < b {} //~ panicking_overflow_checks
8+
if b > a + b {} //~ panicking_overflow_checks
9+
if a - b > b {}
10+
if b < a - b {}
11+
if a - b > a {} //~ panicking_overflow_checks
12+
if a < a - b {} //~ panicking_overflow_checks
13+
if a + b < c {}
14+
if c > a + b {}
15+
if a - b < c {}
16+
if c > a - b {}
17+
let i = 1.1;
18+
let j = 2.2;
19+
if i + j < i {}
20+
if i - j < i {}
21+
if i > i + j {}
22+
if i - j < i {}
23+
}
24+
25+
fn main() {
26+
test(1, 2, 3)
27+
}

tests/ui/overflow_check_conditional.stderr renamed to tests/ui/panicking_overflow_checks.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
error: you are trying to use classic C overflow conditions that will fail in Rust
2-
--> tests/ui/overflow_check_conditional.rs:5:8
2+
--> tests/ui/panicking_overflow_checks.rs:5:8
33
|
44
LL | if a + b < a {}
55
| ^^^^^^^^^
66
|
7-
= note: `-D clippy::overflow-check-conditional` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::overflow_check_conditional)]`
7+
= note: `-D clippy::panicking-overflow-checks` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::panicking_overflow_checks)]`
99

1010
error: you are trying to use classic C overflow conditions that will fail in Rust
11-
--> tests/ui/overflow_check_conditional.rs:6:8
11+
--> tests/ui/panicking_overflow_checks.rs:6:8
1212
|
1313
LL | if a > a + b {}
1414
| ^^^^^^^^^
1515

1616
error: you are trying to use classic C overflow conditions that will fail in Rust
17-
--> tests/ui/overflow_check_conditional.rs:7:8
17+
--> tests/ui/panicking_overflow_checks.rs:7:8
1818
|
1919
LL | if a + b < b {}
2020
| ^^^^^^^^^
2121

2222
error: you are trying to use classic C overflow conditions that will fail in Rust
23-
--> tests/ui/overflow_check_conditional.rs:8:8
23+
--> tests/ui/panicking_overflow_checks.rs:8:8
2424
|
2525
LL | if b > a + b {}
2626
| ^^^^^^^^^
2727

2828
error: you are trying to use classic C overflow conditions that will fail in Rust
29-
--> tests/ui/overflow_check_conditional.rs:11:8
29+
--> tests/ui/panicking_overflow_checks.rs:11:8
3030
|
3131
LL | if a - b > a {}
3232
| ^^^^^^^^^
3333

3434
error: you are trying to use classic C overflow conditions that will fail in Rust
35-
--> tests/ui/overflow_check_conditional.rs:12:8
35+
--> tests/ui/panicking_overflow_checks.rs:12:8
3636
|
3737
LL | if a < a - b {}
3838
| ^^^^^^^^^

tests/ui/rename.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#![allow(clippy::expect_used)]
2525
#![allow(clippy::map_unwrap_or)]
2626
#![allow(clippy::unwrap_used)]
27+
#![allow(clippy::panicking_overflow_checks)]
2728
#![allow(clippy::needless_borrow)]
2829
#![allow(clippy::single_char_add_str)]
2930
#![allow(clippy::module_name_repetitions)]
@@ -77,6 +78,7 @@
7778
#![warn(clippy::option_map_unwrap_or)]
7879
#![warn(clippy::option_map_unwrap_or_else)]
7980
#![warn(clippy::option_unwrap_used)]
81+
#![warn(clippy::overflow_check_conditional)]
8082
#![warn(clippy::ref_in_deref)]
8183
#![warn(clippy::result_expect_used)]
8284
#![warn(clippy::result_map_unwrap_or_else)]

0 commit comments

Comments
 (0)