Skip to content

Commit 95e2bf2

Browse files
authored
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 ```
1 parent 5342d40 commit 95e2bf2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/sys/unix/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ mod inner {
289289

290290
pub fn sub_instant(&self, other: &Instant) -> Duration {
291291
self.t.sub_timespec(&other.t).unwrap_or_else(|_| {
292-
panic!("other was less than the current instant")
292+
panic!("other was greater than the current instant")
293293
})
294294
}
295295

0 commit comments

Comments
 (0)