Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0797712
Stabilize Option::deref and Option::deref_mut
SimonSapin Sep 23, 2019
f1835bc
Stabilize UdpSocket::peer_addr
messense Sep 24, 2019
1d06058
std: Reduce checks for `feature = "backtrace"`
alexcrichton Sep 25, 2019
1de6f74
Update src/libstd/net/udp.rs
Sep 26, 2019
e8796ca
Do not ICE when dereferencing non-Copy raw pointer
estebank Oct 2, 2019
1222cc9
permit asyncawait-ondeck to be added by anyone
nikomatsakis Oct 3, 2019
1fcbd90
Update triagebot.toml
nikomatsakis Oct 3, 2019
ed60cf2
When encountering chained operators use heuristics to recover from ba…
estebank Sep 30, 2019
6c9f298
review comments
estebank Sep 30, 2019
d7dceaa
Account for missing turbofish in paths too
estebank Sep 30, 2019
d27683a
Prove bad turbofish parser recovery in test
estebank Sep 30, 2019
dfdc369
review comments
estebank Oct 1, 2019
f1499a8
review comments
estebank Oct 1, 2019
02f57f8
review comments
estebank Oct 3, 2019
76456e7
review comments
estebank Oct 4, 2019
2d87bac
replace GeneratorSubsts with SubstsRef
csmoe Oct 3, 2019
fa7a87b
generate GeneratorSubsts from SubstsRef
csmoe Oct 3, 2019
774ea80
replace GeneratorSubsts inside related types
csmoe Oct 3, 2019
ef9fe10
remove GeneratorSubsts visitors
csmoe Oct 3, 2019
afc0bb9
clean up GeneratorSubsts
csmoe Oct 3, 2019
e9009c8
[const-prop] Fix ICE when trying to eval polymorphic promoted MIR
wesleywiser Oct 3, 2019
91a096a
move middle::liveness to rustc_passes
Mark-Simulacrum Oct 4, 2019
bb70782
middle::dead -> rustc_passes
Mark-Simulacrum Oct 4, 2019
82bfd8e
middle::entry -> rustc_passes
Mark-Simulacrum Oct 4, 2019
7c3f65b
middle::intrinsicck -> rustc_passes
Mark-Simulacrum Oct 4, 2019
d0a6805
Allow unused attributes to avoid incremental bug
Mark-Simulacrum Oct 4, 2019
d152d48
Fix lonely backtick
Qwaz Oct 4, 2019
c5f80aa
Remove unneeded visit_statement definition
spastorino Oct 4, 2019
8bb5c12
Update the documented default of -Z mutable-noalias
cuviper Oct 4, 2019
5f94a53
Account for macro invocation in `let mut $pat` diagnostic.
Centril Oct 5, 2019
173958a
Replaces some instances of `as *[const | mut] _` with `.cast()`
memoryruins Oct 5, 2019
318ff30
Fix typo on `now()` comments
Oct 5, 2019
080aa86
lint: extern non-exhaustive types are improper
davidtwco Oct 5, 2019
d16b7f7
Revert "Auto merge of #63649 - tlively:emscripten-upstream-upgrade, r…
tmandry Oct 6, 2019
0085263
Rollup merge of #64708 - SimonSapin:option-deref, r=Centril
tmandry Oct 6, 2019
019b5b5
Rollup merge of #64728 - messense:udp-peer-addr, r=dtolnay
tmandry Oct 6, 2019
ae2a720
Rollup merge of #64765 - alexcrichton:less-check-backtrace, r=sfackler
tmandry Oct 6, 2019
c7d7e37
Rollup merge of #64909 - estebank:turbofish-reloaded, r=Centril
tmandry Oct 6, 2019
2b225ba
Rollup merge of #65011 - estebank:ice-o-matic, r=zackmdavis
tmandry Oct 6, 2019
df471c1
Rollup merge of #65064 - rust-lang:permit-asyncawait-ondeck-by-anyone…
tmandry Oct 6, 2019
f14d374
Rollup merge of #65066 - wesleywiser:fix_const_prop_ice_on_polymorphi…
tmandry Oct 6, 2019
7739f17
Rollup merge of #65100 - csmoe:generator, r=nikomatsakis
tmandry Oct 6, 2019
2c8cbcc
Rollup merge of #65105 - Mark-Simulacrum:split-librustc, r=nikomatsakis
tmandry Oct 6, 2019
f80656c
Rollup merge of #65106 - Mark-Simulacrum:unused-attr-allow, r=Centril
tmandry Oct 6, 2019
1ac1407
Rollup merge of #65113 - Qwaz:master, r=jonas-schievink
tmandry Oct 6, 2019
2f4b471
Rollup merge of #65116 - spastorino:remove-unneeded-fn, r=oli-obk
tmandry Oct 6, 2019
a1eac17
Rollup merge of #65118 - cuviper:Zmutable-noalias-default, r=rkruppe
tmandry Oct 6, 2019
f5c8e12
Rollup merge of #65123 - Centril:mac-invoc-in-mut-pat, r=estebank
tmandry Oct 6, 2019
42caed9
Rollup merge of #65124 - memoryruins:castaway, r=petrochenkov
tmandry Oct 6, 2019
d54082e
Rollup merge of #65126 - BO41:time_typo, r=kennytm
tmandry Oct 6, 2019
485f5c9
Rollup merge of #65130 - davidtwco:rfc-2008-improper-ctypes, r=petroc…
tmandry Oct 6, 2019
69598dc
Rollup merge of #65151 - tmandry:revert-emscripten-upgrade, r=tmandry
tmandry Oct 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 23 additions & 28 deletions src/libstd/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
use crate::cmp;
use crate::error::Error;
use crate::fmt;
use crate::ops::{Add, Sub, AddAssign, SubAssign};
use crate::ops::{Add, AddAssign, Sub, SubAssign};
use crate::sys::time;
use crate::sys_common::FromInner;
use crate::sys_common::mutex::Mutex;
use crate::sys_common::FromInner;

#[stable(feature = "time", since = "1.3.0")]
pub use core::time::Duration;
Expand Down Expand Up @@ -216,17 +216,17 @@ impl Instant {
// * https://bugzilla.mozilla.org/show_bug.cgi?id=1487778 - a similar
// Firefox bug
//
// It simply seems that this it just happens so that a lot in the wild
// we're seeing panics across various platforms where consecutive calls
// It seems that this just happens a lot in the wild.
// We're seeing panics across various platforms where consecutive calls
// to `Instant::now`, such as via the `elapsed` function, are panicking
// as they're going backwards. Placed here is a last-ditch effort to try
// to fix things up. We keep a global "latest now" instance which is
// returned instead of what the OS says if the OS goes backwards.
//
// To hopefully mitigate the impact of this though a few platforms are
// To hopefully mitigate the impact of this, a few platforms are
// whitelisted as "these at least haven't gone backwards yet".
if time::Instant::actually_monotonic() {
return Instant(os_now)
return Instant(os_now);
}

static LOCK: Mutex = Mutex::new();
Expand Down Expand Up @@ -353,8 +353,7 @@ impl Add<Duration> for Instant {
///
/// [`checked_add`]: ../../std/time/struct.Instant.html#method.checked_add
fn add(self, other: Duration) -> Instant {
self.checked_add(other)
.expect("overflow when adding duration to instant")
self.checked_add(other).expect("overflow when adding duration to instant")
}
}

Expand All @@ -370,8 +369,7 @@ impl Sub<Duration> for Instant {
type Output = Instant;

fn sub(self, other: Duration) -> Instant {
self.checked_sub(other)
.expect("overflow when subtracting duration from instant")
self.checked_sub(other).expect("overflow when subtracting duration from instant")
}
}

Expand Down Expand Up @@ -464,8 +462,7 @@ impl SystemTime {
/// println!("{:?}", difference);
/// ```
#[stable(feature = "time2", since = "1.8.0")]
pub fn duration_since(&self, earlier: SystemTime)
-> Result<Duration, SystemTimeError> {
pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, SystemTimeError> {
self.0.sub_time(&earlier.0).map_err(SystemTimeError)
}

Expand Down Expand Up @@ -532,8 +529,7 @@ impl Add<Duration> for SystemTime {
///
/// [`checked_add`]: ../../std/time/struct.SystemTime.html#method.checked_add
fn add(self, dur: Duration) -> SystemTime {
self.checked_add(dur)
.expect("overflow when adding duration to instant")
self.checked_add(dur).expect("overflow when adding duration to instant")
}
}

Expand All @@ -549,8 +545,7 @@ impl Sub<Duration> for SystemTime {
type Output = SystemTime;

fn sub(self, dur: Duration) -> SystemTime {
self.checked_sub(dur)
.expect("overflow when subtracting duration from instant")
self.checked_sub(dur).expect("overflow when subtracting duration from instant")
}
}

Expand Down Expand Up @@ -626,7 +621,9 @@ impl SystemTimeError {

#[stable(feature = "time2", since = "1.8.0")]
impl Error for SystemTimeError {
fn description(&self) -> &str { "other time was not earlier than self" }
fn description(&self) -> &str {
"other time was not earlier than self"
}
}

#[stable(feature = "time2", since = "1.8.0")]
Expand All @@ -644,17 +641,16 @@ impl FromInner<time::SystemTime> for SystemTime {

#[cfg(test)]
mod tests {
use super::{Instant, SystemTime, Duration, UNIX_EPOCH};
use super::{Duration, Instant, SystemTime, UNIX_EPOCH};

macro_rules! assert_almost_eq {
($a:expr, $b:expr) => ({
($a:expr, $b:expr) => {{
let (a, b) = ($a, $b);
if a != b {
let (a, b) = if a > b {(a, b)} else {(b, a)};
assert!(a - Duration::new(0, 1000) <= b,
"{:?} is not almost equal to {:?}", a, b);
let (a, b) = if a > b { (a, b) } else { (b, a) };
assert!(a - Duration::new(0, 1000) <= b, "{:?} is not almost equal to {:?}", a, b);
}
})
}};
}

#[test]
Expand Down Expand Up @@ -729,7 +725,7 @@ mod tests {
fn instant_saturating_duration_since_nopanic() {
let a = Instant::now();
let ret = (a - Duration::new(1, 0)).saturating_duration_since(a);
assert_eq!(ret, Duration::new(0,0));
assert_eq!(ret, Duration::new(0, 0));
}

#[test]
Expand All @@ -755,15 +751,14 @@ mod tests {

let second = Duration::new(1, 0);
assert_almost_eq!(a.duration_since(a - second).unwrap(), second);
assert_almost_eq!(a.duration_since(a + second).unwrap_err()
.duration(), second);
assert_almost_eq!(a.duration_since(a + second).unwrap_err().duration(), second);

assert_almost_eq!(a - second + second, a);
assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a);

let one_second_from_epoch = UNIX_EPOCH + Duration::new(1, 0);
let one_second_from_epoch2 = UNIX_EPOCH + Duration::new(0, 500_000_000)
+ Duration::new(0, 500_000_000);
let one_second_from_epoch2 =
UNIX_EPOCH + Duration::new(0, 500_000_000) + Duration::new(0, 500_000_000);
assert_eq!(one_second_from_epoch, one_second_from_epoch2);

// checked_add_duration will not panic on overflow
Expand Down