-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Rollup of 6 pull requests #115303
Rollup of 6 pull requests #115303
Conversation
I edited one of these and looked at the formatted docs for the other. This confused me for a while; I suspected a build system bug. I don't see an easy and neat way to unify these. So let's just document it instead.
* Make the description primary, not the definition in terms of time_t * Remove the list of Internet protocols As per rust-lang#109660 (review)
Document that SystemTime does not count leap seconds Fixes rust-lang#77994 This may not be entirely uncontroversial. I know that `@Ekleog` is going to disagree. However, in support of this docs change: This documents the current behaviour. The alternative would be to plan to *change* the behaviour. There are many programs which need to get a POSIX time (a `time_t`). Right now, `duration_since(UNIX_EPOCH)` is the only facility in std that does that. So, that is what programs use. Changing the behaviour would break[1] all of those programs. We would need to define a new API that can be used to get a POSIX time, and get everyone to use it. This seems highly unpalatable. And, even if we wanted to do that, time with leap seconds is a lot less easy to work with. We would need to arrange to have a leap seconds table available to `std` somehow, and make sure that it was kept up to date. Currently we don't offer to do that for timezone data, which has similar needs. There are other complications. So it seems it would be awkwarrd to *implement* a facility that provides time including leap seconds, and the resulting value would be hard for applications to work with. Therefore, I think it's clear that we don't want to plan to ever change `SystemTime`. We should plan to keep it the way it is. Providing TAI (for example) should be left to external crates, or additional APIs we may add in the future. For more discussion see rust-lang#77994 and in particular `@fanf2's` rust-lang#77994 (comment) [1] Of course, by "break" we really only mean *future* breakage in the case where there is, in fact, ever another leap second. There may well not be: they are in the process of being abolished (although this is of course being contested). But if we decide that `SystemTime::now().duraton_since(UNIX_EPOCH)` counts leap seconds, it would start to return `Durations`s that are 27s different to the current answers. That's clearly unacceptable. And we can hardly change `UNIX_EPOCH` by 27s.
Fix implementation of `Duration::checked_div` I ran across this while running some sanity checks on `time`. Quickcheck immediately found a bug, and as I'd modified the code from `std` I knew there was a bug here as well. tl;dr this code fails ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1189a3efcdfc192c27d6d87815359353)) ```rust use std::time::Duration; fn main() { assert_eq!( Duration::new(1, 1).checked_div(7), Some(Duration::new(0, 142_857_143)), ); } ``` The existing code determines that 1/7 = 0 (seconds), 1/7 = 0 (nanoseconds), 1 billion / 7 = 142,857,142 (extra nanoseconds). The billion comes from multiplying the remainder of the seconds (1) by the number of nanoseconds in a second. However, **this wrongly ignores any remaining nanoseconds**. This PR takes that into consideration, adds a test, and also changes the roundabout way of calculating the remainder into directly computing it. Note: This is _not_ a rounding error. This result divides evenly. `@rustbot` label +A-time +C-bug +S-waiting-on-reviewer +T-libs
std/tests: disable ancillary tests on freebsd since the feature itsel… …f is.
…=calebcartwright style-guide: Add guidance for defining formatting for specific macros
…illaumeGomez tell people what to do when removing an error code Currently tidy and CI send developers on a wild goose chase: - you edit the code - CI/tidy tells you that an error code is gone, so you remove it from the list - CI/tidy tells you that the markdown file is stale, so you remove that as well - CI (but not tidy) tells you not to remove an error description and copy what E0001 does Let's be nice to people and directly tell them what to do rather than making them follow misleading breadcrumbs. r? ``@GuillaumeGomez``
…trace, r=Amanieu avoid triple-backtrace due to panic-during-cleanup Supersedes rust-lang#115020 Cc rust-lang#114954 r? ``@Amanieu``
@bors r+ rollup=never p=6 |
☀️ Test successful - checks-actions |
📌 Perf builds for each rolled up PR:
previous master: 41cb42a370 In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
Finished benchmarking commit (7e02fd8): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 631.418s -> 631.432s (0.00%) |
Successful merges:
Duration::checked_div
#114238 (Fix implementation ofDuration::checked_div
)r? @ghost
@rustbot modify labels: rollup
Create a similar rollup