Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing error message for sub_instant #51255

Merged
merged 2 commits into from
Jun 5, 2018
Merged

Conversation

avdv
Copy link
Contributor

@avdv avdv commented May 31, 2018

When subtracting an Instant from another, the function will panick when RHS > self, but the error message confusingly displays a different error:

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.

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
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 31, 2018
@kennytm
Copy link
Member

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:

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2018
@avdv
Copy link
Contributor Author

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
Copy link
Member

kennytm commented Jun 4, 2018

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 4, 2018

📌 Commit 33c4b37 has been approved by kennytm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 4, 2018
@bors
Copy link
Contributor

bors commented Jun 5, 2018

⌛ Testing commit 33c4b37 with merge 56f7181b2af07b5357d2bd8c7ad4d3e2435a8cf0...

@bors
Copy link
Contributor

bors commented Jun 5, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 5, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[02:25:57] test thread::tests::test_try_panic_message_owned_str ... ok
[02:25:57] test thread::tests::test_try_panic_message_static_str ... ok
[02:25:57] test thread::tests::test_try_panic_message_unit_struct ... ok
[02:25:57] test thread::tests::test_unnamed_thread ... ok
[02:25:57] thread '<unnamed>' panicked at 'specified instant was later than self', libstd/sys/unix/time.rs:292:17
[02:25:57] test time::tests::instant_elapsed ... ok
[02:25:57] test time::tests::instant_math ... ok
[02:25:57] test time::tests::instant_monotonic ... ok
[02:25:57] test time::tests::since_epoch ... ok
---
[02:43:47] [TIMING] Compiletest { compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" }, target: "x86_64-unknown-linux-gnu", mode: "ui", suite: "rustdoc-ui", path: None, compare_mode: None } -- 0.495
[02:43:47] Build completed successfully in 1:43:21
[02:43:47] Distcheck rust-src
[02:43:47]     Updating registry `https://github.com/rust-lang/crates.io-index`
[02:44:27] warning: spurious network error (2 tries remaining): curl error: Couldn't resolve host 'github.com'
[02:44:27] ; class=Net (12)
[02:44:47] warning: spurious network error (1 tries remaining): curl error: Couldn't resolve host 'github.com'
[02:44:47] ; class=Net (12)
[02:45:07] error: failed to load source for a dependency on `rand`
[02:45:07] Caused by:
[02:45:07]   Unable to update registry `https://github.com/rust-lang/crates.io-index`
[02:45:07] 
[02:45:07] Caused by:
[02:45:07] Caused by:
[02:45:07]   failed to fetch `https://github.com/rust-lang/crates.io-index`
[02:45:07] 
[02:45:07] Caused by:
[02:45:07]   curl error: Couldn't resolve host 'github.com'
[02:45:07] ; class=Net (12)
[02:45:07] 
[02:45:07] 
[02:45:07] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "generate-lockfile" "--manifest-path" "/checkout/obj/build/tmp/distcheck-src/rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml"
[02:45:07] 
[02:45:07] 
[02:45:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[02:45:07] Build completed unsuccessfully in 2:42:19

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 @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[02:43:47] [TIMING] Compiletest { compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" }, target: "x86_64-unknown-linux-gnu", mode: "ui", suite: "rustdoc-ui", path: None, compare_mode: None } -- 0.495
[02:43:47] Build completed successfully in 1:43:21
[02:43:47] Distcheck rust-src
[02:43:47]     Updating registry `https://github.com/rust-lang/crates.io-index`
[02:44:27] warning: spurious network error (2 tries remaining): curl error: Couldn't resolve host 'github.com'
[02:44:27] ; class=Net (12)
[02:44:47] warning: spurious network error (1 tries remaining): curl error: Couldn't resolve host 'github.com'
[02:44:47] ; class=Net (12)
[02:45:07] error: failed to load source for a dependency on `rand`
[02:45:07] Caused by:
[02:45:07]   Unable to update registry `https://github.com/rust-lang/crates.io-index`
[02:45:07] 
[02:45:07] Caused by:
[02:45:07] Caused by:
[02:45:07]   failed to fetch `https://github.com/rust-lang/crates.io-index`
[02:45:07] 
[02:45:07] Caused by:
[02:45:07]   curl error: Couldn't resolve host 'github.com'
[02:45:07] ; class=Net (12)
[02:45:07] 
[02:45:07] 
[02:45:07] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "generate-lockfile" "--manifest-path" "/checkout/obj/build/tmp/distcheck-src/rust-src/lib/rustlib/src/rust/src/libstd/Cargo.toml"
[02:45:07] 
[02:45:07] 
[02:45:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[02:45:07] Build completed unsuccessfully in 2:42:19

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 @TimNN. (Feature Requests)

@kennytm
Copy link
Member

kennytm commented Jun 5, 2018

@bors retry travis-ci/travis-ci#9696

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 5, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request 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.
bors added a commit that referenced this pull request Jun 5, 2018
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:
@bors bors merged commit 33c4b37 into rust-lang:master Jun 5, 2018
@avdv avdv deleted the patch-1 branch June 5, 2018 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants