From 45fde0f86f6f90a6e235e5eac420725ccc5aa66a Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Wed, 4 Sep 2019 21:06:28 +0900 Subject: [PATCH] Fix doctest and renaming src --- ...nwrap_or.rs => manual_saturating_arithmetic.rs} | 0 clippy_lints/src/methods/mod.rs | 14 ++++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) rename clippy_lints/src/methods/{checked_arith_unwrap_or.rs => manual_saturating_arithmetic.rs} (100%) diff --git a/clippy_lints/src/methods/checked_arith_unwrap_or.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs similarity index 100% rename from clippy_lints/src/methods/checked_arith_unwrap_or.rs rename to clippy_lints/src/methods/manual_saturating_arithmetic.rs diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 4c1f13daa24..c9ca622a440 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1,4 +1,4 @@ -mod checked_arith_unwrap_or; +mod manual_saturating_arithmetic; mod option_map_unwrap_or; mod unnecessary_filter_map; @@ -994,15 +994,17 @@ declare_clippy_lint! { /// ```rust /// let x: u32 = 100; /// - /// let add = x.checked_add(y).unwrap_or(u32::max_value()); - /// let sub = x.checked_sub(y).unwrap_or(u32::min_value()); + /// let add = x.checked_add(3).unwrap_or(u32::max_value()); + /// let sub = x.checked_sub(3).unwrap_or(u32::min_value()); /// ``` /// /// can be written using dedicated methods for saturating addition/subtraction as: /// /// ```rust - /// let add = x.saturating_add(y); - /// let sub = x.saturating_sub(y); + /// let x: u32 = 100; + /// + /// let add = x.saturating_add(3); + /// let sub = x.saturating_sub(3); /// ``` pub MANUAL_SATURATING_ARITHMETIC, style, @@ -1102,7 +1104,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods { ["unwrap_or", arith @ "checked_add"] | ["unwrap_or", arith @ "checked_sub"] | ["unwrap_or", arith @ "checked_mul"] => { - checked_arith_unwrap_or::lint(cx, expr, &arg_lists, &arith["checked_".len()..]) + manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..]) }, _ => {}, }