Skip to content

Commit 4fc0ee6

Browse files
committed
[1/N] Implement Arithmetic lint
1 parent 1dd5547 commit 4fc0ee6

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

clippy_lints/src/lib.register_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ store.register_lints(&[
3535
utils::internal_lints::UNNECESSARY_SYMBOL_STR,
3636
absurd_extreme_comparisons::ABSURD_EXTREME_COMPARISONS,
3737
approx_const::APPROX_CONSTANT,
38-
arithmetic::FLOAT_ARITHMETIC,
39-
arithmetic::INTEGER_ARITHMETIC,
4038
as_conversions::AS_CONVERSIONS,
4139
asm_syntax::INLINE_ASM_X86_ATT_SYNTAX,
4240
asm_syntax::INLINE_ASM_X86_INTEL_SYNTAX,
@@ -420,6 +418,8 @@ store.register_lints(&[
420418
non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS,
421419
non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY,
422420
nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES,
421+
numeric_arithmetic::FLOAT_ARITHMETIC,
422+
numeric_arithmetic::INTEGER_ARITHMETIC,
423423
octal_escapes::OCTAL_ESCAPES,
424424
only_used_in_recursion::ONLY_USED_IN_RECURSION,
425425
open_options::NONSENSICAL_OPEN_OPTIONS,

clippy_lints/src/lib.register_restriction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Manual edits will be overwritten.
44

55
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
6-
LintId::of(arithmetic::FLOAT_ARITHMETIC),
7-
LintId::of(arithmetic::INTEGER_ARITHMETIC),
86
LintId::of(as_conversions::AS_CONVERSIONS),
97
LintId::of(asm_syntax::INLINE_ASM_X86_ATT_SYNTAX),
108
LintId::of(asm_syntax::INLINE_ASM_X86_INTEL_SYNTAX),
@@ -50,6 +48,8 @@ store.register_group(true, "clippy::restriction", Some("clippy_restriction"), ve
5048
LintId::of(module_style::MOD_MODULE_FILES),
5149
LintId::of(module_style::SELF_NAMED_MODULE_FILES),
5250
LintId::of(modulo_arithmetic::MODULO_ARITHMETIC),
51+
LintId::of(numeric_arithmetic::FLOAT_ARITHMETIC),
52+
LintId::of(numeric_arithmetic::INTEGER_ARITHMETIC),
5353
LintId::of(panic_in_result_fn::PANIC_IN_RESULT_FN),
5454
LintId::of(panic_unimplemented::PANIC),
5555
LintId::of(panic_unimplemented::TODO),

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ mod renamed_lints;
169169
// begin lints modules, do not remove this comment, it’s used in `update_lints`
170170
mod absurd_extreme_comparisons;
171171
mod approx_const;
172-
mod arithmetic;
173172
mod as_conversions;
174173
mod asm_syntax;
175174
mod assertions_on_constants;
@@ -328,6 +327,7 @@ mod non_expressive_names;
328327
mod non_octal_unix_permissions;
329328
mod non_send_fields_in_send_ty;
330329
mod nonstandard_macro_braces;
330+
mod numeric_arithmetic;
331331
mod octal_escapes;
332332
mod only_used_in_recursion;
333333
mod open_options;
@@ -678,7 +678,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
678678
store.register_late_pass(move || Box::new(doc::DocMarkdown::new(doc_valid_idents.clone())));
679679
store.register_late_pass(|| Box::new(neg_multiply::NegMultiply));
680680
store.register_late_pass(|| Box::new(mem_forget::MemForget));
681-
store.register_late_pass(|| Box::new(arithmetic::Arithmetic::default()));
681+
store.register_late_pass(|| Box::new(numeric_arithmetic::NumericArithmetic::default()));
682682
store.register_late_pass(|| Box::new(assign_ops::AssignOps));
683683
store.register_late_pass(|| Box::new(let_if_seq::LetIfSeq));
684684
store.register_late_pass(|| Box::new(mixed_read_write_in_expression::EvalOrderDependence));

clippy_lints/src/arithmetic.rs renamed to clippy_lints/src/numeric_arithmetic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ declare_clippy_lint! {
5151
}
5252

5353
#[derive(Copy, Clone, Default)]
54-
pub struct Arithmetic {
54+
pub struct NumericArithmetic {
5555
expr_span: Option<Span>,
5656
/// This field is used to check whether expressions are constants, such as in enum discriminants
5757
/// and consts
5858
const_span: Option<Span>,
5959
}
6060

61-
impl_lint_pass!(Arithmetic => [INTEGER_ARITHMETIC, FLOAT_ARITHMETIC]);
61+
impl_lint_pass!(NumericArithmetic => [INTEGER_ARITHMETIC, FLOAT_ARITHMETIC]);
6262

63-
impl<'tcx> LateLintPass<'tcx> for Arithmetic {
63+
impl<'tcx> LateLintPass<'tcx> for NumericArithmetic {
6464
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
6565
if self.expr_span.is_some() {
6666
return;

0 commit comments

Comments
 (0)