Rustup to rustc 1.35.0-nightly (82e2f3ec2 2019-03-20)
This commit is contained in:
parent
788d8cec93
commit
a715c79263
@ -1,10 +1,10 @@
|
||||
#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_error_handler)]
|
||||
#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_prelude, alloc_error_handler)]
|
||||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
extern crate alloc_system;
|
||||
|
||||
use alloc::prelude::*;
|
||||
use alloc::prelude::v1::*;
|
||||
|
||||
use alloc_system::System;
|
||||
|
||||
|
@ -54,14 +54,16 @@ index d0ee5fa..d02c454 100644
|
||||
macro_rules! ptr_width {
|
||||
() => { 2 }
|
||||
diff --git a/src/libcore/time.rs b/src/libcore/time.rs
|
||||
index 91161ca..759497f 100644
|
||||
index ae6d807..4414e07 100644
|
||||
--- a/src/libcore/time.rs
|
||||
+++ b/src/libcore/time.rs
|
||||
@@ -518,80 +469,6 @@ impl Duration {
|
||||
(self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64)
|
||||
@@ -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.
|
||||
-
|
||||
- /// 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`.
|
||||
@ -71,12 +73,14 @@ index 91161ca..759497f 100644
|
||||
- /// #![feature(duration_float)]
|
||||
- /// use std::time::Duration;
|
||||
- ///
|
||||
- /// let dur = Duration::from_float_secs(2.7);
|
||||
- /// 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_float_secs(secs: f64) -> Duration {
|
||||
- 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");
|
||||
@ -94,6 +98,42 @@ index 91161ca..759497f 100644
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /// 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
|
||||
@ -111,7 +151,29 @@ index 91161ca..759497f 100644
|
||||
- #[unstable(feature = "duration_float", issue = "54361")]
|
||||
- #[inline]
|
||||
- pub fn mul_f64(self, rhs: f64) -> Duration {
|
||||
- Duration::from_float_secs(rhs * self.as_float_secs())
|
||||
- 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`.
|
||||
@ -132,12 +194,68 @@ index 91161ca..759497f 100644
|
||||
- #[unstable(feature = "duration_float", issue = "54361")]
|
||||
- #[inline]
|
||||
- pub fn div_f64(self, rhs: f64) -> Duration {
|
||||
- Duration::from_float_secs(self.as_float_secs() / rhs)
|
||||
- Duration::from_secs_f64(self.as_secs_f64() / rhs)
|
||||
- }
|
||||
-
|
||||
/// Divide `Duration` by `Duration` and return `f64`.
|
||||
///
|
||||
/// # Examples
|
||||
- /// 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
|
||||
|
@ -3,7 +3,7 @@ use std::borrow::Cow;
|
||||
use rustc::mir::interpret::{
|
||||
read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar,
|
||||
};
|
||||
use rustc::ty::{Const, LazyConst};
|
||||
use rustc::ty::Const;
|
||||
use rustc_mir::interpret::{
|
||||
EvalContext, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer,
|
||||
StackPopCleanup,
|
||||
@ -76,18 +76,18 @@ pub fn trans_constant<'a, 'tcx: 'a>(
|
||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||
constant: &Constant<'tcx>,
|
||||
) -> CValue<'tcx> {
|
||||
let const_ = fx.monomorphize(&constant.literal);
|
||||
let const_ = force_eval_const(fx, const_);
|
||||
let const_ = force_eval_const(fx, &constant.literal);
|
||||
trans_const_value(fx, const_)
|
||||
}
|
||||
|
||||
pub fn force_eval_const<'a, 'tcx: 'a>(
|
||||
fx: &FunctionCx<'a, 'tcx, impl Backend>,
|
||||
const_: &'tcx LazyConst<'tcx>,
|
||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||
const_: &'tcx Const,
|
||||
) -> Const<'tcx> {
|
||||
match *const_ {
|
||||
LazyConst::Unevaluated(def_id, ref substs) => {
|
||||
match const_.val {
|
||||
ConstValue::Unevaluated(def_id, ref substs) => {
|
||||
let param_env = ParamEnv::reveal_all();
|
||||
let substs = fx.monomorphize(substs);
|
||||
let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap();
|
||||
let cid = GlobalId {
|
||||
instance,
|
||||
@ -95,7 +95,7 @@ pub fn force_eval_const<'a, 'tcx: 'a>(
|
||||
};
|
||||
fx.tcx.const_eval(param_env.and(cid)).unwrap()
|
||||
}
|
||||
LazyConst::Evaluated(const_) => const_,
|
||||
_ => *fx.monomorphize(&const_),
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
|
||||
span: DUMMY_SP,
|
||||
ty: const_.ty,
|
||||
user_ty: None,
|
||||
literal: fx.tcx.mk_lazy_const(LazyConst::Evaluated(const_)),
|
||||
literal: fx.tcx.mk_const(const_),
|
||||
})),
|
||||
None,
|
||||
)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user