diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index aefe4690b106c..72a8f31cec18b 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1015,8 +1015,7 @@ impl f32 { /// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` - // The tests below invoke `clamp` without a return value in order to cause a `panic`. - // #[must_use = "method returns a new number and does not mutate the original value"] + #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f32, max: f32) -> f32 { @@ -1631,18 +1630,18 @@ mod tests { #[test] #[should_panic] fn test_clamp_min_greater_than_max() { - 1.0f32.clamp(3.0, 1.0); + let _ = 1.0f32.clamp(3.0, 1.0); } #[test] #[should_panic] fn test_clamp_min_is_nan() { - 1.0f32.clamp(NAN, 1.0); + let _ = 1.0f32.clamp(NAN, 1.0); } #[test] #[should_panic] fn test_clamp_max_is_nan() { - 1.0f32.clamp(3.0, NAN); + let _ = 1.0f32.clamp(3.0, NAN); } } diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 0eca1434a637f..762a87e257279 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -936,8 +936,7 @@ impl f64 { /// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0); /// assert!((std::f64::NAN).clamp(-2.0, 1.0).is_nan()); /// ``` - // The tests below invoke `clamp` without a return value in order to cause a `panic`. - // #[must_use = "method returns a new number and does not mutate the original value"] + #[must_use = "method returns a new number and does not mutate the original value"] #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f64, max: f64) -> f64 { @@ -1571,18 +1570,18 @@ mod tests { #[test] #[should_panic] fn test_clamp_min_greater_than_max() { - 1.0f64.clamp(3.0, 1.0); + let _ = 1.0f64.clamp(3.0, 1.0); } #[test] #[should_panic] fn test_clamp_min_is_nan() { - 1.0f64.clamp(NAN, 1.0); + let _ = 1.0f64.clamp(NAN, 1.0); } #[test] #[should_panic] fn test_clamp_max_is_nan() { - 1.0f64.clamp(3.0, NAN); + let _ = 1.0f64.clamp(3.0, NAN); } }