Skip to content

Commit a715c79

Browse files
committed
Rustup to rustc 1.35.0-nightly (82e2f3ec2 2019-03-20)
1 parent 788d8ce commit a715c79

File tree

3 files changed

+141
-23
lines changed

3 files changed

+141
-23
lines changed

example/alloc_example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_error_handler)]
1+
#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_prelude, alloc_error_handler)]
22
#![no_std]
33

44
extern crate alloc;
55
extern crate alloc_system;
66

7-
use alloc::prelude::*;
7+
use alloc::prelude::v1::*;
88

99
use alloc_system::System;
1010

patches/0002-Disable-u128-and-i128-in-libcore.patch

Lines changed: 130 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ index d0ee5fa..d02c454 100644
5454
macro_rules! ptr_width {
5555
() => { 2 }
5656
diff --git a/src/libcore/time.rs b/src/libcore/time.rs
57-
index 91161ca..759497f 100644
57+
index ae6d807..4414e07 100644
5858
--- a/src/libcore/time.rs
5959
+++ b/src/libcore/time.rs
60-
@@ -518,80 +469,6 @@ impl Duration {
61-
(self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64)
60+
@@ -534,198 +534,6 @@ impl Duration {
61+
pub const fn as_secs_f32(&self) -> f32 {
62+
(self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32)
6263
}
63-
64-
- /// Creates a new `Duration` from the specified number of seconds.
64+
-
65+
- /// Creates a new `Duration` from the specified number of seconds represented
66+
- /// as `f64`.
6567
- ///
6668
- /// # Panics
6769
- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`.
@@ -71,12 +73,14 @@ index 91161ca..759497f 100644
7173
- /// #![feature(duration_float)]
7274
- /// use std::time::Duration;
7375
- ///
74-
- /// let dur = Duration::from_float_secs(2.7);
76+
- /// let dur = Duration::from_secs_f64(2.7);
7577
- /// assert_eq!(dur, Duration::new(2, 700_000_000));
7678
- /// ```
7779
- #[unstable(feature = "duration_float", issue = "54361")]
7880
- #[inline]
79-
- pub fn from_float_secs(secs: f64) -> Duration {
81+
- pub fn from_secs_f64(secs: f64) -> Duration {
82+
- const MAX_NANOS_F64: f64 =
83+
- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;
8084
- let nanos = secs * (NANOS_PER_SEC as f64);
8185
- if !nanos.is_finite() {
8286
- panic!("got non-finite value when converting float to duration");
@@ -94,6 +98,42 @@ index 91161ca..759497f 100644
9498
- }
9599
- }
96100
-
101+
- /// Creates a new `Duration` from the specified number of seconds represented
102+
- /// as `f32`.
103+
- ///
104+
- /// # Panics
105+
- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`.
106+
- ///
107+
- /// # Examples
108+
- /// ```
109+
- /// #![feature(duration_float)]
110+
- /// use std::time::Duration;
111+
- ///
112+
- /// let dur = Duration::from_secs_f32(2.7);
113+
- /// assert_eq!(dur, Duration::new(2, 700_000_000));
114+
- /// ```
115+
- #[unstable(feature = "duration_float", issue = "54361")]
116+
- #[inline]
117+
- pub fn from_secs_f32(secs: f32) -> Duration {
118+
- const MAX_NANOS_F32: f32 =
119+
- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f32;
120+
- let nanos = secs * (NANOS_PER_SEC as f32);
121+
- if !nanos.is_finite() {
122+
- panic!("got non-finite value when converting float to duration");
123+
- }
124+
- if nanos >= MAX_NANOS_F32 {
125+
- panic!("overflow when converting float to duration");
126+
- }
127+
- if nanos < 0.0 {
128+
- panic!("underflow when converting float to duration");
129+
- }
130+
- let nanos = nanos as u128;
131+
- Duration {
132+
- secs: (nanos / (NANOS_PER_SEC as u128)) as u64,
133+
- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32,
134+
- }
135+
- }
136+
-
97137
- /// Multiplies `Duration` by `f64`.
98138
- ///
99139
- /// # Panics
@@ -111,7 +151,29 @@ index 91161ca..759497f 100644
111151
- #[unstable(feature = "duration_float", issue = "54361")]
112152
- #[inline]
113153
- pub fn mul_f64(self, rhs: f64) -> Duration {
114-
- Duration::from_float_secs(rhs * self.as_float_secs())
154+
- Duration::from_secs_f64(rhs * self.as_secs_f64())
155+
- }
156+
-
157+
- /// Multiplies `Duration` by `f32`.
158+
- ///
159+
- /// # Panics
160+
- /// This method will panic if result is not finite, negative or overflows `Duration`.
161+
- ///
162+
- /// # Examples
163+
- /// ```
164+
- /// #![feature(duration_float)]
165+
- /// use std::time::Duration;
166+
- ///
167+
- /// let dur = Duration::new(2, 700_000_000);
168+
- /// // note that due to rounding errors result is slightly different
169+
- /// // from 8.478 and 847800.0
170+
- /// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_640));
171+
- /// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847799, 969_120_256));
172+
- /// ```
173+
- #[unstable(feature = "duration_float", issue = "54361")]
174+
- #[inline]
175+
- pub fn mul_f32(self, rhs: f32) -> Duration {
176+
- Duration::from_secs_f32(rhs * self.as_secs_f32())
115177
- }
116178
-
117179
- /// Divide `Duration` by `f64`.
@@ -132,12 +194,68 @@ index 91161ca..759497f 100644
132194
- #[unstable(feature = "duration_float", issue = "54361")]
133195
- #[inline]
134196
- pub fn div_f64(self, rhs: f64) -> Duration {
135-
- Duration::from_float_secs(self.as_float_secs() / rhs)
197+
- Duration::from_secs_f64(self.as_secs_f64() / rhs)
198+
- }
199+
-
200+
- /// Divide `Duration` by `f32`.
201+
- ///
202+
- /// # Panics
203+
- /// This method will panic if result is not finite, negative or overflows `Duration`.
204+
- ///
205+
- /// # Examples
206+
- /// ```
207+
- /// #![feature(duration_float)]
208+
- /// use std::time::Duration;
209+
- ///
210+
- /// let dur = Duration::new(2, 700_000_000);
211+
- /// // note that due to rounding errors result is slightly
212+
- /// // different from 0.859_872_611
213+
- /// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_576));
214+
- /// // note that truncation is used, not rounding
215+
- /// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_598));
216+
- /// ```
217+
- #[unstable(feature = "duration_float", issue = "54361")]
218+
- #[inline]
219+
- pub fn div_f32(self, rhs: f32) -> Duration {
220+
- Duration::from_secs_f32(self.as_secs_f32() / rhs)
221+
- }
222+
-
223+
- /// Divide `Duration` by `Duration` and return `f64`.
224+
- ///
225+
- /// # Examples
226+
- /// ```
227+
- /// #![feature(duration_float)]
228+
- /// use std::time::Duration;
229+
- ///
230+
- /// let dur1 = Duration::new(2, 700_000_000);
231+
- /// let dur2 = Duration::new(5, 400_000_000);
232+
- /// assert_eq!(dur1.div_duration_f64(dur2), 0.5);
233+
- /// ```
234+
- #[unstable(feature = "duration_float", issue = "54361")]
235+
- #[inline]
236+
- pub fn div_duration_f64(self, rhs: Duration) -> f64 {
237+
- self.as_secs_f64() / rhs.as_secs_f64()
136238
- }
137239
-
138-
/// Divide `Duration` by `Duration` and return `f64`.
139-
///
140-
/// # Examples
240+
- /// Divide `Duration` by `Duration` and return `f32`.
241+
- ///
242+
- /// # Examples
243+
- /// ```
244+
- /// #![feature(duration_float)]
245+
- /// use std::time::Duration;
246+
- ///
247+
- /// let dur1 = Duration::new(2, 700_000_000);
248+
- /// let dur2 = Duration::new(5, 400_000_000);
249+
- /// assert_eq!(dur1.div_duration_f32(dur2), 0.5);
250+
- /// ```
251+
- #[unstable(feature = "duration_float", issue = "54361")]
252+
- #[inline]
253+
- pub fn div_duration_f32(self, rhs: Duration) -> f32 {
254+
- self.as_secs_f32() / rhs.as_secs_f32()
255+
- }
256+
}
257+
258+
#[stable(feature = "duration", since = "1.3.0")]
141259
diff --git a/src/libstd/num.rs b/src/libstd/num.rs
142260
index 828d572..bc04fb1 100644
143261
--- a/src/libstd/num.rs

src/constant.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::borrow::Cow;
33
use rustc::mir::interpret::{
44
read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar,
55
};
6-
use rustc::ty::{Const, LazyConst};
6+
use rustc::ty::Const;
77
use rustc_mir::interpret::{
88
EvalContext, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer,
99
StackPopCleanup,
@@ -76,26 +76,26 @@ pub fn trans_constant<'a, 'tcx: 'a>(
7676
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
7777
constant: &Constant<'tcx>,
7878
) -> CValue<'tcx> {
79-
let const_ = fx.monomorphize(&constant.literal);
80-
let const_ = force_eval_const(fx, const_);
79+
let const_ = force_eval_const(fx, &constant.literal);
8180
trans_const_value(fx, const_)
8281
}
8382

8483
pub fn force_eval_const<'a, 'tcx: 'a>(
85-
fx: &FunctionCx<'a, 'tcx, impl Backend>,
86-
const_: &'tcx LazyConst<'tcx>,
84+
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
85+
const_: &'tcx Const,
8786
) -> Const<'tcx> {
88-
match *const_ {
89-
LazyConst::Unevaluated(def_id, ref substs) => {
87+
match const_.val {
88+
ConstValue::Unevaluated(def_id, ref substs) => {
9089
let param_env = ParamEnv::reveal_all();
90+
let substs = fx.monomorphize(substs);
9191
let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap();
9292
let cid = GlobalId {
9393
instance,
9494
promoted: None,
9595
};
9696
fx.tcx.const_eval(param_env.and(cid)).unwrap()
9797
}
98-
LazyConst::Evaluated(const_) => const_,
98+
_ => *fx.monomorphize(&const_),
9999
}
100100
}
101101

@@ -152,7 +152,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
152152
span: DUMMY_SP,
153153
ty: const_.ty,
154154
user_ty: None,
155-
literal: fx.tcx.mk_lazy_const(LazyConst::Evaluated(const_)),
155+
literal: fx.tcx.mk_const(const_),
156156
})),
157157
None,
158158
)?;

0 commit comments

Comments
 (0)