about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKyle Strand <kyle.strand@rms.com>2019-09-05 10:22:11 -0600
committerKyle Strand <kyle.strand@rms.com>2019-09-05 10:22:11 -0600
commit1aa5d0cace3a72ae23f32ece5bb18085b36b5258 (patch)
tree42fbc5be89ccb967a4d303bc6b54ae1d632bee63
parent54cb728ab8b89ef31578455031519101a93dadc7 (diff)
downloadrust-1aa5d0cace3a72ae23f32ece5bb18085b36b5258.tar.gz
rust-1aa5d0cace3a72ae23f32ece5bb18085b36b5258.zip
Restore 'must_use' for 'clamp'; fix warning for tests
-rw-r--r--src/libstd/f32.rs9
-rw-r--r--src/libstd/f64.rs9
2 files changed, 8 insertions, 10 deletions
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs
index aefe4690b10..72a8f31cec1 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 0eca1434a63..762a87e2572 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);
     }
 }