Skip to content

Commit 51d8b6c

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

File tree

15 files changed

+31
-27
lines changed

15 files changed

+31
-27
lines changed

CHANGELOG.md

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

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

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

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

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

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

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

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

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

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)