Skip to content

Commit 51d8b6c

Browse files
committed
Rename the arithmetic lint
1 parent 617417e commit 51d8b6c

15 files changed

+31
-27
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3583,7 +3583,7 @@ Released 2018-09-13
35833583
[`almost_complete_letter_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_letter_range
35843584
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
35853585
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
3586-
[`arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic
3586+
[`arithmetic_side_effects`]: https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects
35873587
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
35883588
[`as_underscore`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore
35893589
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants

clippy_lints/src/lib.register_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ store.register_lints(&[
437437
octal_escapes::OCTAL_ESCAPES,
438438
only_used_in_recursion::ONLY_USED_IN_RECURSION,
439439
operators::ABSURD_EXTREME_COMPARISONS,
440-
operators::ARITHMETIC,
440+
operators::ARITHMETIC_SIDE_EFFECTS,
441441
operators::ASSIGN_OP_PATTERN,
442442
operators::BAD_BIT_MASK,
443443
operators::CMP_NAN,

clippy_lints/src/lib.register_restriction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ store.register_group(true, "clippy::restriction", Some("clippy_restriction"), ve
5050
LintId::of(mixed_read_write_in_expression::MIXED_READ_WRITE_IN_EXPRESSION),
5151
LintId::of(module_style::MOD_MODULE_FILES),
5252
LintId::of(module_style::SELF_NAMED_MODULE_FILES),
53-
LintId::of(operators::ARITHMETIC),
53+
LintId::of(operators::ARITHMETIC_SIDE_EFFECTS),
5454
LintId::of(operators::FLOAT_ARITHMETIC),
5555
LintId::of(operators::FLOAT_CMP_CONST),
5656
LintId::of(operators::INTEGER_ARITHMETIC),

clippy_lints/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,12 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
544544
store.register_late_pass(|| Box::new(utils::internal_lints::MsrvAttrImpl));
545545
}
546546

547-
let arithmetic_allowed = conf.arithmetic_allowed.clone();
548-
store.register_late_pass(move || Box::new(operators::arithmetic::Arithmetic::new(arithmetic_allowed.clone())));
547+
let arithmetic_side_effects_allowed = conf.arithmetic_side_effects_allowed.clone();
548+
store.register_late_pass(move || {
549+
Box::new(operators::arithmetic_side_effects::ArithmeticSideEffects::new(
550+
arithmetic_side_effects_allowed.clone(),
551+
))
552+
});
549553
store.register_late_pass(|| Box::new(utils::dump_hir::DumpHir));
550554
store.register_late_pass(|| Box::new(utils::author::Author));
551555
let await_holding_invalid_types = conf.await_holding_invalid_types.clone();

clippy_lints/src/operators/arithmetic.rs renamed to clippy_lints/src/operators/arithmetic_side_effects.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
clippy::match_same_arms
44
)]
55

6-
use super::ARITHMETIC;
6+
use super::ARITHMETIC_SIDE_EFFECTS;
77
use clippy_utils::{consts::constant_simple, diagnostics::span_lint};
88
use rustc_ast as ast;
99
use rustc_data_structures::fx::FxHashSet;
@@ -22,16 +22,16 @@ const HARD_CODED_ALLOWED: &[&str] = &[
2222
];
2323

2424
#[derive(Debug)]
25-
pub struct Arithmetic {
25+
pub struct ArithmeticSideEffects {
2626
allowed: FxHashSet<String>,
2727
// Used to check whether expressions are constants, such as in enum discriminants and consts
2828
const_span: Option<Span>,
2929
expr_span: Option<Span>,
3030
}
3131

32-
impl_lint_pass!(Arithmetic => [ARITHMETIC]);
32+
impl_lint_pass!(ArithmeticSideEffects => [ARITHMETIC_SIDE_EFFECTS]);
3333

34-
impl Arithmetic {
34+
impl ArithmeticSideEffects {
3535
#[must_use]
3636
pub fn new(mut allowed: FxHashSet<String>) -> Self {
3737
allowed.extend(HARD_CODED_ALLOWED.iter().copied().map(String::from));
@@ -83,7 +83,7 @@ impl Arithmetic {
8383
}
8484

8585
fn issue_lint(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) {
86-
span_lint(cx, ARITHMETIC, expr.span, "arithmetic detected");
86+
span_lint(cx, ARITHMETIC_SIDE_EFFECTS, expr.span, "arithmetic detected");
8787
self.expr_span = Some(expr.span);
8888
}
8989

@@ -125,7 +125,7 @@ impl Arithmetic {
125125
}
126126
}
127127

128-
impl<'tcx> LateLintPass<'tcx> for Arithmetic {
128+
impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
129129
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
130130
if self.expr_span.is_some() || self.const_span.map_or(false, |sp| sp.contains(expr.span)) {
131131
return;

clippy_lints/src/operators/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod ptr_eq;
2121
mod self_assignment;
2222
mod verbose_bit_mask;
2323

24-
pub(crate) mod arithmetic;
24+
pub(crate) mod arithmetic_side_effects;
2525

2626
use rustc_hir::{Body, Expr, ExprKind, UnOp};
2727
use rustc_lint::{LateContext, LateLintPass};
@@ -92,11 +92,11 @@ declare_clippy_lint! {
9292
/// ```
9393
///
9494
/// ### Allowed types
95-
/// Custom allowed types can be specified through the "arithmetic-allowed" filter.
95+
/// Custom allowed types can be specified through the "arithmetic-side-effects-allowed" filter.
9696
#[clippy::version = "1.64.0"]
97-
pub ARITHMETIC,
97+
pub ARITHMETIC_SIDE_EFFECTS,
9898
restriction,
99-
"any arithmetic expression that could overflow or panic"
99+
"any arithmetic expression that can cause side effects like overflows or panics"
100100
}
101101

102102
declare_clippy_lint! {
@@ -789,7 +789,7 @@ pub struct Operators {
789789
}
790790
impl_lint_pass!(Operators => [
791791
ABSURD_EXTREME_COMPARISONS,
792-
ARITHMETIC,
792+
ARITHMETIC_SIDE_EFFECTS,
793793
INTEGER_ARITHMETIC,
794794
FLOAT_ARITHMETIC,
795795
ASSIGN_OP_PATTERN,

clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ define_Conf! {
208208
/// Lint: Arithmetic.
209209
///
210210
/// Suppress checking of the passed type names.
211-
(arithmetic_allowed: rustc_data_structures::fx::FxHashSet<String> = <_>::default()),
211+
(arithmetic_side_effects_allowed: rustc_data_structures::fx::FxHashSet<String> = <_>::default()),
212212
/// Lint: ENUM_VARIANT_NAMES, LARGE_TYPES_PASSED_BY_VALUE, TRIVIALLY_COPY_PASS_BY_REF, UNNECESSARY_WRAPS, UNUSED_SELF, UPPER_CASE_ACRONYMS, WRONG_SELF_CONVENTION, BOX_COLLECTION, REDUNDANT_ALLOCATION, RC_BUFFER, VEC_BOX, OPTION_OPTION, LINKEDLIST, RC_MUTEX.
213213
///
214214
/// Suppress lints whenever the suggested change would cause breakage for other crates.

src/docs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ docs! {
2626
"almost_complete_letter_range",
2727
"almost_swapped",
2828
"approx_constant",
29-
"arithmetic",
29+
"arithmetic_side_effects",
3030
"as_conversions",
3131
"as_underscore",
3232
"assertions_on_constants",

src/docs/arithmetic.txt renamed to src/docs/arithmetic_side_effects.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ let _n = Decimal::MAX + Decimal::MAX;
3030
```
3131

3232
### Allowed types
33-
Custom allowed types can be specified through the "arithmetic-allowed" filter.
33+
Custom allowed types can be specified through the "arithmetic-side-effects-allowed" filter.

tests/ui-toml/arithmetic_allowed/clippy.toml

-1
This file was deleted.

tests/ui-toml/arithmetic_allowed/arithmetic_allowed.rs renamed to tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::arithmetic)]
1+
#![warn(clippy::arithmetic_side_effects)]
22

33
use core::ops::Add;
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
arithmetic-side-effects-allowed = ["Point"]

tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown fie
33
allow-expect-in-tests
44
allow-unwrap-in-tests
55
allowed-scripts
6-
arithmetic-allowed
6+
arithmetic-side-effects-allowed
77
array-size-threshold
88
avoid-breaking-exported-api
99
await-holding-invalid-types

tests/ui/arithmetic.rs renamed to tests/ui/arithmetic_side_effects.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::assign_op_pattern, clippy::unnecessary_owned_empty_strings)]
22
#![feature(inline_const, saturating_int_impl)]
3-
#![warn(clippy::arithmetic)]
3+
#![warn(clippy::arithmetic_side_effects)]
44

55
use core::num::{Saturating, Wrapping};
66

tests/ui/arithmetic.stderr renamed to tests/ui/arithmetic_side_effects.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error: arithmetic detected
2-
--> $DIR/arithmetic.rs:50:21
2+
--> $DIR/arithmetic_side_effects.rs:50:21
33
|
44
LL | let mut _a = 1; _a += 1;
55
| ^^^^^^^
66
|
7-
= note: `-D clippy::arithmetic` implied by `-D warnings`
7+
= note: `-D clippy::arithmetic-side-effects` implied by `-D warnings`
88

99
error: arithmetic detected
10-
--> $DIR/arithmetic.rs:52:26
10+
--> $DIR/arithmetic_side_effects.rs:52:26
1111
|
1212
LL | let mut _b = 1; _b = _b + 1;
1313
| ^^^^^^
1414

1515
error: arithmetic detected
16-
--> $DIR/arithmetic.rs:54:26
16+
--> $DIR/arithmetic_side_effects.rs:54:26
1717
|
1818
LL | let mut _c = 1; _c = 1 + _c;
1919
| ^^^^^^

0 commit comments

Comments
 (0)