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

Add a niche to Duration, unix SystemTime, and non-apple Instant #102368

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

beetrees
Copy link
Contributor

As the nanoseconds fields is always between 0 and (NANOS_PER_SEC - 1) inclusive, use the rustc_layout_scalar_valid_range attributes to create a niche in the nanosecond field of Duration and Timespec (which is used to implement unix SystemTime and non-apple unix Instant; windows Instant is implemented with Duration and therefore will also benefit). This change has the benefit of making Option<T> the same size as T for the previously mentioned types. Also shrinks the nanoseconds field of Timespec to a u32 as nanoseconds do not need the extra range of an i64, shrinking Timespec by 4 bytes on 32-bit platforms.

r? @joshtriplett

@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 @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot
Copy link
Collaborator

rustbot commented Sep 27, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 27, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 27, 2022
@joshtriplett
Copy link
Member

r=me with repr(transparent) added as @CryZe requested. Nice work!

@beetrees
Copy link
Contributor Author

@joshtriplett #[repr(transparent)] added as requested.

@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 28, 2022

📌 Commit b9b969a has been approved by joshtriplett

It is now in the queue for this repository.

@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 Sep 28, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Sep 28, 2022
Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`

As the nanoseconds fields is always between `0` and `(NANOS_PER_SEC - 1)` inclusive, use the `rustc_layout_scalar_valid_range` attributes to create a niche in the nanosecond field of `Duration` and `Timespec` (which is used to implement unix `SystemTime` and non-apple unix `Instant`; windows `Instant` is implemented with `Duration` and therefore will also benefit). This change has the benefit of making `Option<T>` the same size as `T` for the previously mentioned types. Also shrinks the nanoseconds field of `Timespec` to a `u32` as nanoseconds do not need the extra range of an `i64`, shrinking `Timespec` by 4 bytes on 32-bit platforms.

r? `@joshtriplett`
@Dylan-DPC
Copy link
Member

failed in rollup

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 28, 2022
@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 28, 2022

📌 Commit a913277 has been approved by joshtriplett

It is now in the queue for this repository.

@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 Sep 28, 2022
@CryZe
Copy link
Contributor

CryZe commented Sep 28, 2022

The debugger visualization / natvis for Windows wasn't adjusted to handle the new struct.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Sep 29, 2022
Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`

As the nanoseconds fields is always between `0` and `(NANOS_PER_SEC - 1)` inclusive, use the `rustc_layout_scalar_valid_range` attributes to create a niche in the nanosecond field of `Duration` and `Timespec` (which is used to implement unix `SystemTime` and non-apple unix `Instant`; windows `Instant` is implemented with `Duration` and therefore will also benefit). This change has the benefit of making `Option<T>` the same size as `T` for the previously mentioned types. Also shrinks the nanoseconds field of `Timespec` to a `u32` as nanoseconds do not need the extra range of an `i64`, shrinking `Timespec` by 4 bytes on 32-bit platforms.

r? `@joshtriplett`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Sep 29, 2022
Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`

As the nanoseconds fields is always between `0` and `(NANOS_PER_SEC - 1)` inclusive, use the `rustc_layout_scalar_valid_range` attributes to create a niche in the nanosecond field of `Duration` and `Timespec` (which is used to implement unix `SystemTime` and non-apple unix `Instant`; windows `Instant` is implemented with `Duration` and therefore will also benefit). This change has the benefit of making `Option<T>` the same size as `T` for the previously mentioned types. Also shrinks the nanoseconds field of `Timespec` to a `u32` as nanoseconds do not need the extra range of an `i64`, shrinking `Timespec` by 4 bytes on 32-bit platforms.

r? ``@joshtriplett``
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 29, 2022
Rollup of 8 pull requests

Successful merges:

 - rust-lang#98368 (Make `std::os::fd` public.)
 - rust-lang#102085 (Code refactoring smart_resolve_report_errors)
 - rust-lang#102351 (Improve E0585 help)
 - rust-lang#102368 (Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`)
 - rust-lang#102393 (Add regression test for issue 94923)
 - rust-lang#102399 (Account for use of index-based lifetime names in print of binder)
 - rust-lang#102416 (remove FIXME, improve documentation)
 - rust-lang#102433 (env::temp_dir: fix a typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8e4869e into rust-lang:master Sep 29, 2022
@rustbot rustbot added this to the 1.66.0 milestone Sep 29, 2022
@beetrees beetrees deleted the nano-niche branch March 30, 2023 14:36
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants