about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAda Alakbarova <ada.alakbarova@proton.me>2025-05-26 00:21:04 +0200
committerAda Alakbarova <ada.alakbarova@proton.me>2025-05-26 00:25:16 +0200
commit93a509fca3071f50fae92e51dfcbccecb3c96e94 (patch)
treede86655cf642eb440d8691c5f538611efb8a66e7
parentb6b97a741cad25bb9cd3250544b6fe06a1ab59cd (diff)
downloadrust-93a509fca3071f50fae92e51dfcbccecb3c96e94.tar.gz
rust-93a509fca3071f50fae92e51dfcbccecb3c96e94.zip
exhaustive match instead of returns
-rw-r--r--clippy_lints/src/operators/modulo_arithmetic.rs29
1 files changed, 11 insertions, 18 deletions
diff --git a/clippy_lints/src/operators/modulo_arithmetic.rs b/clippy_lints/src/operators/modulo_arithmetic.rs
index 691d7b904ef..8f28b7bb390 100644
--- a/clippy_lints/src/operators/modulo_arithmetic.rs
+++ b/clippy_lints/src/operators/modulo_arithmetic.rs
@@ -60,31 +60,24 @@ fn analyze_operand(operand: &Expr<'_>, cx: &LateContext<'_>, expr: &Expr<'_>) ->
         Some(Constant::Int(v)) => match *cx.typeck_results().expr_ty(expr).kind() {
             ty::Int(ity) => {
                 let value = sext(cx.tcx, v, ity);
-                return Some(OperandInfo {
+                Some(OperandInfo {
                     string_representation: Some(value.to_string()),
                     is_negative: value < 0,
                     is_integral: true,
-                });
+                })
             },
-            ty::Uint(_) => {
-                return Some(OperandInfo {
-                    string_representation: None,
-                    is_negative: false,
-                    is_integral: true,
-                });
-            },
-            _ => {},
+            ty::Uint(_) => Some(OperandInfo {
+                string_representation: None,
+                is_negative: false,
+                is_integral: true,
+            }),
+            _ => None,
         },
         // FIXME(f16_f128): add when casting is available on all platforms
-        Some(Constant::F32(f)) => {
-            return Some(floating_point_operand_info(&f));
-        },
-        Some(Constant::F64(f)) => {
-            return Some(floating_point_operand_info(&f));
-        },
-        _ => {},
+        Some(Constant::F32(f)) => Some(floating_point_operand_info(&f)),
+        Some(Constant::F64(f)) => Some(floating_point_operand_info(&f)),
+        _ => None,
     }
-    None
 }
 
 fn floating_point_operand_info<T: Display + PartialOrd + From<f32>>(f: &T) -> OperandInfo {