about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Rapp <t.rapp@noa-archive.com>2020-05-04 17:32:27 +0200
committerTobias Rapp <t.rapp@noa-archive.com>2020-05-04 17:32:27 +0200
commitf99344ace44abc91f76df276625e048f1e8a9536 (patch)
treeab122be879fc6d9f4e93b1719f0b080744e4aa43
parentff4df04799c406c8149a041c3163321758aac924 (diff)
downloadrust-f99344ace44abc91f76df276625e048f1e8a9536.tar.gz
rust-f99344ace44abc91f76df276625e048f1e8a9536.zip
Stabilize saturating_abs and saturating_neg
Stabilizes the following signed integer functions with saturation
mechanics:
 * saturating_abs()
 * saturating_neg()

Closes #59983
-rw-r--r--src/libcore/num/mod.rs10
-rw-r--r--src/libcore/tests/lib.rs1
-rw-r--r--src/test/ui/consts/const-int-arithmetic.rs1
3 files changed, 4 insertions, 8 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index a259e293b0c..d600b8e1c25 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -1114,8 +1114,7 @@ instead of overflowing.
 Basic usage:
 
 ```
-", $Feature, "#![feature(saturating_neg)]
-assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
+", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
 assert_eq!((-100", stringify!($SelfT), ").saturating_neg(), 100);
 assert_eq!(", stringify!($SelfT), "::MIN.saturating_neg(), ", stringify!($SelfT),
 "::MAX);
@@ -1124,7 +1123,7 @@ assert_eq!(", stringify!($SelfT), "::MAX.saturating_neg(), ", stringify!($SelfT)
 $EndFeature, "
 ```"),
 
-            #[unstable(feature = "saturating_neg", issue = "59983")]
+            #[stable(feature = "saturating_neg", since = "1.45.0")]
             #[rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718")]
             #[inline]
             pub const fn saturating_neg(self) -> Self {
@@ -1141,8 +1140,7 @@ MIN` instead of overflowing.
 Basic usage:
 
 ```
-", $Feature, "#![feature(saturating_neg)]
-assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
+", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
 assert_eq!((-100", stringify!($SelfT), ").saturating_abs(), 100);
 assert_eq!(", stringify!($SelfT), "::MIN.saturating_abs(), ", stringify!($SelfT),
 "::MAX);
@@ -1151,7 +1149,7 @@ assert_eq!((", stringify!($SelfT), "::MIN + 1).saturating_abs(), ", stringify!($
 $EndFeature, "
 ```"),
 
-            #[unstable(feature = "saturating_neg", issue = "59983")]
+            #[stable(feature = "saturating_neg", since = "1.45.0")]
             #[rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718")]
             #[inline]
             pub const fn saturating_abs(self) -> Self {
diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs
index e7d36d327cd..6a297f0dc03 100644
--- a/src/libcore/tests/lib.rs
+++ b/src/libcore/tests/lib.rs
@@ -17,7 +17,6 @@
 #![feature(pattern)]
 #![feature(range_is_empty)]
 #![feature(raw)]
-#![feature(saturating_neg)]
 #![feature(sort_internals)]
 #![feature(slice_partition_at_index)]
 #![feature(specialization)]
diff --git a/src/test/ui/consts/const-int-arithmetic.rs b/src/test/ui/consts/const-int-arithmetic.rs
index 2c3421b7a8d..ab24abeba32 100644
--- a/src/test/ui/consts/const-int-arithmetic.rs
+++ b/src/test/ui/consts/const-int-arithmetic.rs
@@ -1,6 +1,5 @@
 // run-pass
 
-#![feature(saturating_neg)]
 #![feature(const_checked_int_methods)]
 #![feature(const_euclidean_int_methods)]
 #![feature(const_overflowing_int_methods)]