Uh oh!
There was an error while loading. Please reload this page.
Fix confusing error message for sub_instant - #51255
Conversation
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
```rust-highfive
commented
May 31, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
kennytm
commented
May 31, 2018
Thank you @avdv! Would you mind updating this file as well? Also, I think the error message from the Windows and CloudABI implementations are even more clearer: |
Uses the same wording as [`src/libstd/sys/windows/time.rs`][1]. 1: https://github.com/avdv/rust/blob/95e2bf253d864c5e14ad000ffa2040ce85916056/src/libstd/sys/windows/time.rs#L65
avdv
commented
Jun 4, 2018
Hi @kennytm, I went with the first alternative phrase; I liked it the best. I updated the PR accordingly. Cheers. |
kennytm
commented
Jun 4, 2018
@bors r+ rollup |
bors
commented
Jun 4, 2018
📌 Commit 33c4b37 has been approved by |
bors
commented
Jun 5, 2018
⌛ Testing commit 33c4b37 with merge 56f7181b2af07b5357d2bd8c7ad4d3e2435a8cf0... |
bors
commented
Jun 5, 2018
💔 Test failed - status-travis |
rust-highfive
commented
Jun 5, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Jun 5, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
kennytm
commented
Jun 5, 2018
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.Rollup of 7 pull requests Successful merges: - #50852 (Add doc comment to hiding portions of code example) - #51183 (Update rustdoc book to suggest using Termination trait instead of hidden ‘foo’ function) - #51255 (Fix confusing error message for sub_instant) - #51256 (Fix crate-name option in rustdoc) - #51308 (Check array indices in constant propagation) - #51343 (test: Ignore some problematic tests on sparc and sparc64) - #51358 (Tests that #39963 is fixed on MIR borrowck) Failed merges:
When subtracting an Instant from another, the function will panick when
RHS > self, but the error message confusingly displays a different error:This results in a panic:
But clearly,
otherwas actually greater than the current instant.