about summary refs log tree commit diff
path: root/clippy_lints/src/arithmetic.rs
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2021-02-09 11:15:53 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2021-02-09 11:39:20 +0300
commit34b373d309e05dec9d7409bc2481668778ebc600 (patch)
treefcbcf96ce4d7a4318c9f4d1728ab1c1986b91fee /clippy_lints/src/arithmetic.rs
parenta5d442cdf950a2aca7d967eb94443fd6f154381c (diff)
Rename HIR UnOp variants
This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like "&*" instead of just "*".
Diffstat (limited to 'clippy_lints/src/arithmetic.rs')
-rw-r--r--clippy_lints/src/arithmetic.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs
index 9861d8cfc4e..61fdf9495b9 100644
--- a/clippy_lints/src/arithmetic.rs
+++ b/clippy_lints/src/arithmetic.rs
@@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
                     match op.node {
                         hir::BinOpKind::Div | hir::BinOpKind::Rem => match &r.kind {
                             hir::ExprKind::Lit(_lit) => (),
-                            hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) => {
+                            hir::ExprKind::Unary(hir::UnOp::Neg, expr) => {
                                 if let hir::ExprKind::Lit(lit) = &expr.kind {
                                     if let rustc_ast::ast::LitKind::Int(1, _) = lit.node {
                                         span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
@@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
                     self.expr_span = Some(expr.span);
                 }
             },
-            hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
+            hir::ExprKind::Unary(hir::UnOp::Neg, arg) => {
                 let ty = cx.typeck_results().expr_ty(arg);
                 if constant_simple(cx, cx.typeck_results(), expr).is_none() {
                     if ty.is_integral() {