Skip to content

Commit

Permalink
Reduce patching of libcore a bit
Browse files Browse the repository at this point in the history
These parts are no longer necessary as of #627
  • Loading branch information
bjorn3 committed Jul 26, 2019
1 parent a302f88 commit 8506784
Showing 1 changed file with 0 additions and 203 deletions.
203 changes: 0 additions & 203 deletions patches/0002-Disable-u128-and-i128-in-libcore.patch
Original file line number Diff line number Diff line change
Expand Up @@ -68,209 +68,6 @@ index d0ee5fa..d02c454 100644
#[cfg(target_pointer_width = "16")]
macro_rules! ptr_width {
() => { 2 }
diff --git a/src/libcore/time.rs b/src/libcore/time.rs
index ae6d807..4414e07 100644
--- a/src/libcore/time.rs
+++ b/src/libcore/time.rs
@@ -534,198 +534,6 @@ impl Duration {
pub const fn as_secs_f32(&self) -> f32 {
(self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32)
}
-
- /// Creates a new `Duration` from the specified number of seconds represented
- /// as `f64`.
- ///
- /// # Panics
- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur = Duration::from_secs_f64(2.7);
- /// assert_eq!(dur, Duration::new(2, 700_000_000));
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn from_secs_f64(secs: f64) -> Duration {
- const MAX_NANOS_F64: f64 =
- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;
- let nanos = secs * (NANOS_PER_SEC as f64);
- if !nanos.is_finite() {
- panic!("got non-finite value when converting float to duration");
- }
- if nanos >= MAX_NANOS_F64 {
- panic!("overflow when converting float to duration");
- }
- if nanos < 0.0 {
- panic!("underflow when converting float to duration");
- }
- let nanos = nanos as u128;
- Duration {
- secs: (nanos / (NANOS_PER_SEC as u128)) as u64,
- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32,
- }
- }
-
- /// Creates a new `Duration` from the specified number of seconds represented
- /// as `f32`.
- ///
- /// # Panics
- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur = Duration::from_secs_f32(2.7);
- /// assert_eq!(dur, Duration::new(2, 700_000_000));
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn from_secs_f32(secs: f32) -> Duration {
- const MAX_NANOS_F32: f32 =
- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f32;
- let nanos = secs * (NANOS_PER_SEC as f32);
- if !nanos.is_finite() {
- panic!("got non-finite value when converting float to duration");
- }
- if nanos >= MAX_NANOS_F32 {
- panic!("overflow when converting float to duration");
- }
- if nanos < 0.0 {
- panic!("underflow when converting float to duration");
- }
- let nanos = nanos as u128;
- Duration {
- secs: (nanos / (NANOS_PER_SEC as u128)) as u64,
- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32,
- }
- }
-
- /// Multiplies `Duration` by `f64`.
- ///
- /// # Panics
- /// This method will panic if result is not finite, negative or overflows `Duration`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur = Duration::new(2, 700_000_000);
- /// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000));
- /// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0));
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn mul_f64(self, rhs: f64) -> Duration {
- Duration::from_secs_f64(rhs * self.as_secs_f64())
- }
-
- /// Multiplies `Duration` by `f32`.
- ///
- /// # Panics
- /// This method will panic if result is not finite, negative or overflows `Duration`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur = Duration::new(2, 700_000_000);
- /// // note that due to rounding errors result is slightly different
- /// // from 8.478 and 847800.0
- /// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_640));
- /// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847799, 969_120_256));
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn mul_f32(self, rhs: f32) -> Duration {
- Duration::from_secs_f32(rhs * self.as_secs_f32())
- }
-
- /// Divide `Duration` by `f64`.
- ///
- /// # Panics
- /// This method will panic if result is not finite, negative or overflows `Duration`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur = Duration::new(2, 700_000_000);
- /// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611));
- /// // note that truncation is used, not rounding
- /// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598));
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn div_f64(self, rhs: f64) -> Duration {
- Duration::from_secs_f64(self.as_secs_f64() / rhs)
- }
-
- /// Divide `Duration` by `f32`.
- ///
- /// # Panics
- /// This method will panic if result is not finite, negative or overflows `Duration`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur = Duration::new(2, 700_000_000);
- /// // note that due to rounding errors result is slightly
- /// // different from 0.859_872_611
- /// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_576));
- /// // note that truncation is used, not rounding
- /// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_598));
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn div_f32(self, rhs: f32) -> Duration {
- Duration::from_secs_f32(self.as_secs_f32() / rhs)
- }
-
- /// Divide `Duration` by `Duration` and return `f64`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur1 = Duration::new(2, 700_000_000);
- /// let dur2 = Duration::new(5, 400_000_000);
- /// assert_eq!(dur1.div_duration_f64(dur2), 0.5);
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn div_duration_f64(self, rhs: Duration) -> f64 {
- self.as_secs_f64() / rhs.as_secs_f64()
- }
-
- /// Divide `Duration` by `Duration` and return `f32`.
- ///
- /// # Examples
- /// ```
- /// #![feature(duration_float)]
- /// use std::time::Duration;
- ///
- /// let dur1 = Duration::new(2, 700_000_000);
- /// let dur2 = Duration::new(5, 400_000_000);
- /// assert_eq!(dur1.div_duration_f32(dur2), 0.5);
- /// ```
- #[unstable(feature = "duration_float", issue = "54361")]
- #[inline]
- pub fn div_duration_f32(self, rhs: Duration) -> f32 {
- self.as_secs_f32() / rhs.as_secs_f32()
- }
}

#[stable(feature = "duration", since = "1.3.0")]
diff --git a/src/libstd/num.rs b/src/libstd/num.rs
index 828d572..bc04fb1 100644
--- a/src/libstd/num.rs
Expand Down

0 comments on commit 8506784

Please sign in to comment.