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

Move Duration to libcore #46666

Merged
merged 1 commit into from
Jan 31, 2018
Merged

Move Duration to libcore #46666

merged 1 commit into from
Jan 31, 2018

Conversation

clarfonthey
Copy link
Contributor

Fixes #46520; should be merged after #46508.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@kennytm kennytm added S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 11, 2017
@clarfonthey clarfonthey force-pushed the duration_core branch 2 times, most recently from 483a3cd to ab0b5a8 Compare December 12, 2017 16:31
///
/// let duration = Duration::from_millis(5432);
/// assert_eq!(duration.as_secs(), 5);
/// assert_eq!(duration.subsec_nanos(), 432_000_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subsec_millis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of #46508

///
/// let duration = Duration::from_micros(1_234_567);
/// assert_eq!(duration.as_secs(), 1);
/// assert_eq!(duration.subsec_nanos(), 234_567_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subsec_micros?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of #46508

@kennytm
Copy link
Member

kennytm commented Dec 20, 2017

#46508 has been merged. @clarcharr

@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-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Dec 20, 2017
@bors
Copy link
Contributor

bors commented Dec 20, 2017

☔ The latest upstream changes (presumably #46874) made this pull request unmergeable. Please resolve the merge conflicts.

@clarfonthey
Copy link
Contributor Author

@kennytm Just rebased! Waiting on CI.

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 21, 2017
@@ -7,6 +7,19 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![stable(feature = "duration", since = "1.3.0")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the module level stability here be updated to 1.24.0 with a new feature name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure! My assumption is that because we're simply moving what was already stable in std to core, that we should use the same feature and version. But I can update it or mark it as unstable if desired.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type's stability definitely shouldn't change, but its placement in libcore is new. If nothing else, it's a nice indication in rustdoc as to when it first showed up.

@aturon what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sfackler makes sense! considering how libstd will always show up on docs searches before libcore, this should help. I'll make this change and then wait for @aturon's response.

@@ -45,7 +58,7 @@ const MICROS_PER_SEC: u64 = 1_000_000;
///
/// let ten_millis = Duration::from_millis(10);
/// ```
#[stable(feature = "duration", since = "1.3.0")]
#![stable(feature = "duration_core", since = "1.24.0")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add the ! here...

[00:03:27] error: an inner attribute is not permitted following an outer doc comment
[00:03:27]   --> /checkout/src/libcore/time.rs:61:3
[00:03:27]    |
[00:03:27] 61 | #![stable(feature = "duration_core", since = "1.24.0")]
[00:03:27]    |   ^
[00:03:27]    |
[00:03:27]    = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…I copy-pasted and shouldn't have.

@clarfonthey
Copy link
Contributor Author

(it is passing now)

@bors
Copy link
Contributor

bors commented Dec 22, 2017

☔ The latest upstream changes (presumably #46922) made this pull request unmergeable. Please resolve the merge conflicts.

@sfackler
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 23, 2017

📌 Commit 3f6b8e1 has been approved by sfackler

@sfackler
Copy link
Member

@bors r-

@sfackler
Copy link
Member

Er, actually, let's make sure the rest of the libs folks are okay with this since the move is insta-stable.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Dec 23, 2017

Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged teams:

Concerns:

Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Dec 23, 2017
@kennytm kennytm added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 23, 2017
@clarfonthey
Copy link
Contributor Author

clarfonthey commented Jan 12, 2018

@alexcrichton I mean, that PR is two years old and Rust has gained a lot of no_std crates in that timeframe. I don't really know what sort of examples I can give, other than stating that time measurement is something that shows up in embedded systems all the time. If I wanted to code a simple OS in Rust I'd have to do all time measurement with a custom Duration struct, or probably just an int measuring nanoseconds, which seems unnecessary considering how all that work is already done in the standard library.

Pre-1.0 I actually used a bit of Rust for a systems programming class, and although Duration didn't exist at the time, if I were to code such a thing now I'd definitely be a bit upset that this is included in libstd despite definitely being a system-agnostic type.

To flip the question: do you have any vague idea of what an std-requiring Duration would look like? What kind of functionality would need to be system-specific and not included in a separate type like SystemTime or Instant?

(to add: if Duration represented a moment in time I would absolutely agree with you, but it represents the distance between two points in time, which is much different)

@bors
Copy link
Contributor

bors commented Jan 12, 2018

☔ The latest upstream changes (presumably #47392) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

Ah sorry I meant to comment on this but forgot! The @rust-lang/libs team discussed this PR at triage last week and the conclusion was that we should go ahead and move forward with it. Our thinking was that we can't think of any functionality we'd really like to add to Duration any time soon which requires libstd, and if this does come about we can always figure out a solution. In the meantime Duration also has a pro in that it's so simple, so it seems fine to include in libcore.

@clarcharr want to rebase before merging?

@rfcbot fcp merge

@alexcrichton
Copy link
Member

Also can you move the tests to an the src/libcore/tests folder? The inline tests in the module won't be run I believe.

@kennytm
Copy link
Member

kennytm commented Jan 16, 2018

rfcbot is not responding 😕

@alexcrichton
Copy link
Member

er sorry that's my mistake, it was already done above!

@rfcbot resolved we-may-want-std

@rfcbot
Copy link

rfcbot commented Jan 16, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jan 16, 2018
@kennytm kennytm removed the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Jan 16, 2018
@clarfonthey
Copy link
Contributor Author

Just realised that one primary use of libstd Duration is to have a static method which times the duration a function takes to execute, and imo that would be better suited for the to-be-stabled Bencher from libtest

@alexcrichton
Copy link
Member

That was an example of what we felt wasn't necessarily critical functionality to have but something we could stabilize at a later date via other means. How does that sound to you though?

@clarfonthey
Copy link
Contributor Author

Seems fine to me!

@Mark-Simulacrum
Copy link
Member

So I believe the consensus here is we want to merge this, but are waiting on a rebase. Is that correct?

@alexcrichton
Copy link
Member

Indeed!

@rfcbot
Copy link

rfcbot commented Jan 26, 2018

The final comment period is now complete.

@clarfonthey
Copy link
Contributor Author

Rebased!

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jan 30, 2018

📌 Commit aab712c has been approved by alexcrichton

@kennytm kennytm 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 Jan 30, 2018
@bors
Copy link
Contributor

bors commented Jan 31, 2018

⌛ Testing commit aab712c with merge b8f2674...

bors added a commit that referenced this pull request Jan 31, 2018
Move Duration to libcore

Fixes #46520; should be merged after #46508.
@bors
Copy link
Contributor

bors commented Jan 31, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing b8f2674 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants