Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement checked_add_duration for SystemTime #55527
Conversation
rust-highfive
assigned
sfackler
Oct 31, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (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
added
the
S-waiting-on-review
label
Oct 31, 2018
sgeisler
force-pushed the
sgeisler:time-checked-add
branch
from
0a87de2
to
3aced4c
Oct 31, 2018
This comment has been minimized.
This comment has been minimized.
|
I just noticed that I also need to make make |
sgeisler
changed the title
Implement checked_add_duration for SystemTime
WIP: Implement checked_add_duration for SystemTime
Oct 31, 2018
sgeisler
force-pushed the
sgeisler:time-checked-add
branch
from
3aced4c
to
dd605a1
Nov 1, 2018
sgeisler
changed the title
WIP: Implement checked_add_duration for SystemTime
Implement checked_add_duration for SystemTime
Nov 2, 2018
This comment has been minimized.
This comment has been minimized.
|
I think the PR is ready for review/an automated all-platforms test run. Is there an easy way to just try to compile it on all platforms? |
sgeisler
referenced this pull request
Nov 3, 2018
Merged
Use std::time API instead of u64s for timestamp and expiry time #8
sfackler
reviewed
Nov 5, 2018
src/libstd/time.rs Outdated
sgeisler
force-pushed the
sgeisler:time-checked-add
branch
from
687eac9
to
52ba35d
Nov 5, 2018
This comment has been minimized.
This comment has been minimized.
|
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 |
sgeisler
force-pushed the
sgeisler:time-checked-add
branch
from
52ba35d
to
74d7fba
Nov 5, 2018
sfackler
reviewed
Nov 13, 2018
src/libstd/time.rs Outdated
This comment has been minimized.
This comment has been minimized.
|
LGTM with the issue number changed! |
sgeisler
referenced this pull request
Nov 13, 2018
Closed
Tracking issue for `time_checked_add` feature #55940
sgeisler
force-pushed the
sgeisler:time-checked-add
branch
from
74d7fba
to
8e4711d
Nov 13, 2018
This comment has been minimized.
This comment has been minimized.
|
When will the full test suite (all platforms) be run? I expect some problems at first due to conditional compilation (which I can't test). |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ It'll run now! No worries if it bounces a couple of times due to the platform specific stuff - it happens all the time. |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Nov 14, 2018
kennytm
added a commit
to kennytm/rust
that referenced
this pull request
Nov 14, 2018
bors
added a commit
that referenced
this pull request
Nov 14, 2018
bors
added a commit
that referenced
this pull request
Nov 14, 2018
bors
added a commit
that referenced
this pull request
Nov 14, 2018
kennytm
reviewed
Nov 14, 2018
src/libstd/sys/wasm/time.rs Outdated
This comment has been minimized.
This comment has been minimized.
|
@bors r- Failed in #55943 (comment) on wasm32. |
bors
added a commit
that referenced
this pull request
Nov 15, 2018
bors
added a commit
that referenced
this pull request
Nov 16, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Nov 16, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Nov 16, 2018
This comment has been minimized.
This comment has been minimized.
|
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 |
sgeisler
added some commits
Oct 31, 2018
sgeisler
force-pushed the
sgeisler:time-checked-add
branch
from
8231831
to
f2106d0
Nov 16, 2018
bors
added a commit
that referenced
this pull request
Nov 16, 2018
This comment has been minimized.
This comment has been minimized.
|
Triage; @sfackler Hello, have you been able to get back to this PR? |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Nov 25, 2018
This comment has been minimized.
This comment has been minimized.
|
Sorry, missed that you updated this - github doesn't notify on force pushes :( |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Nov 25, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit f2106d0
into
rust-lang:master
Nov 25, 2018
sgeisler
deleted the
sgeisler:time-checked-add
branch
Dec 14, 2018
vi
added a commit
to vi/rust
that referenced
this pull request
Feb 12, 2019
vi
added a commit
to vi/rust
that referenced
this pull request
Feb 12, 2019
This comment has been minimized.
This comment has been minimized.
|
This PR acknowledges that |
This comment has been minimized.
This comment has been minimized.
|
Yeah, seems best to alter the tests to avoid pre-epoch times if those aren't universally supported. |
sgeisler commentedOct 31, 2018
•
edited
Original discussion on the rust user forum
Since
SystemTimeis opaque there is no way to check if the result of an addition will be in bounds. That makes theAdd<Duration>trait completely unusable with untrusted data. This is a big problem because adding aDurationtoUNIX_EPOCHis the standard way of constructing aSystemTimefrom a unix timestamp.This PR implements
checked_add_duration(&self, &Duration) -> Option<SystemTime>forstd::time::SystemTimeand as a prerequisite also for all platform specific time structs. This also led to the refactoring of manyadd_duration(&self, &Duration) -> SystemTimefunctions to avoid redundancy (they now unwrap the result ofchecked_add_duration).Some basic unit tests for the newly introduced function were added too.
I wasn't sure which stabilization attribute to add to the newly introduced function, so I just chose
#[stable(feature = "time_checked_add", since = "1.32.0")]for now to make it compile. Please let me know how I should change it or if I violated any other conventions.P.S.: I could only test on Linux so far, so I don't necessarily expect it to compile for all platforms.