diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2018-06-05 08:33:46 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-05 08:33:46 -0600 |
| commit | 753e8f328fc12af94aab75aa3d4172f2b61769cc (patch) | |
| tree | ed8e7147544418c943d6fbded70be7da954d982f /src/libstd/sys | |
| parent | 1225faf1a410cbb6df347bd135fb3460cfd2a5ce (diff) | |
| parent | 33c4b37d00985f8f12796ef1b0b8ff97a4f3db99 (diff) | |
| download | rust-753e8f328fc12af94aab75aa3d4172f2b61769cc.tar.gz rust-753e8f328fc12af94aab75aa3d4172f2b61769cc.zip | |
Rollup merge of #51255 - avdv:patch-1, r=kennytm
Fix confusing error message for sub_instant
When subtracting an Instant from another, the function will panick when `RHS > self`, but the error message confusingly displays a different error:
```rust
let i = Instant::now();
let other = Instant::now();
if other > i {
println!("{:?}", i - other);
}
```
This results in a panic:
```
thread 'test_instant' panicked at 'other was less than the current instant', libstd/sys/unix/time.rs:292:17
```
But clearly, `other` was actually greater than the current instant.
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/redox/time.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/time.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/sys/redox/time.rs b/src/libstd/sys/redox/time.rs index cf798500b7f..5c491115c55 100644 --- a/src/libstd/sys/redox/time.rs +++ b/src/libstd/sys/redox/time.rs @@ -144,7 +144,7 @@ impl Instant { pub fn sub_instant(&self, other: &Instant) -> Duration { self.t.sub_timespec(&other.t).unwrap_or_else(|_| { - panic!("other was less than the current instant") + panic!("specified instant was later than self") }) } diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 83127935909..89786eb2a6c 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -289,7 +289,7 @@ mod inner { pub fn sub_instant(&self, other: &Instant) -> Duration { self.t.sub_timespec(&other.t).unwrap_or_else(|_| { - panic!("other was less than the current instant") + panic!("specified instant was later than self") }) } |
