Skip to content

Rollup of 9 pull requests #120837

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

Closed
wants to merge 28 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8a850cd
std/time: avoid divisions in Duration::new
utkarshgupta137 Jan 24, 2024
8148053
Add supporting infrastructure for `run-make` V2 tests
jieyouxu Jan 20, 2024
e1826bf
Point to stage1-std when in stage2 rustc
jieyouxu Feb 2, 2024
c2a0d11
Fix incorrect stage std paths
jieyouxu Feb 2, 2024
0ac1195
Invert diagnostic lints.
nnethercote Feb 5, 2024
ad3d04c
A drive-by rewrite of give_region_a_name()
amandasystems Feb 6, 2024
0f323b2
Associated types in traits don't necessarily have a type that we can …
oli-obk Feb 7, 2024
0b97d18
extern types don't have any types to visit
oli-obk Feb 7, 2024
b998b51
Actually walk fields of Adt definitions
oli-obk Feb 7, 2024
4389a1c
Stop using `hir_ty_to_ty` in rustc_privacy
oli-obk Jul 18, 2023
5c25de6
Remove now-useless method override
oli-obk Feb 7, 2024
e867886
Remove dead code
oli-obk Feb 7, 2024
795be51
Make `RegionName` `Copy` by (transitively) interning the few string v…
amandasystems Feb 7, 2024
d80d7ea
Add some tests for associated type normalization edge cases
oli-obk Feb 8, 2024
d70d320
Use `transmute_unchecked` in `NonZero::new`.
reitermarkus Feb 8, 2024
698a3c7
Don't ICE in ByMoveBody when coroutine is tainted
compiler-errors Feb 8, 2024
e32c1dd
Don't ice in validation when error body is created
compiler-errors Feb 9, 2024
7619792
Fix `ErrorGuaranteed` unsoundness with stash/steal.
nnethercote Feb 8, 2024
575e0aa
Startup objects disappearing from sysroot
Nikokrock Feb 9, 2024
163510f
Rollup merge of #113026 - jieyouxu:run-make-v2, r=bjorn3
matthiaskrgr Feb 9, 2024
8bc0462
Rollup merge of #113671 - oli-obk:normalize_weak_tys, r=petrochenkov
matthiaskrgr Feb 9, 2024
e34ea3e
Rollup merge of #120308 - utkarshgupta137:duration-opt, r=m-ou-se
matthiaskrgr Feb 9, 2024
16a17e6
Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davi…
matthiaskrgr Feb 9, 2024
c8d7eda
Rollup merge of #120704 - amandasystems:silly-region-name-rewrite, r=…
matthiaskrgr Feb 9, 2024
8ebe9f0
Rollup merge of #120809 - reitermarkus:generic-nonzero-constructors, …
matthiaskrgr Feb 9, 2024
8946437
Rollup merge of #120817 - compiler-errors:more-mir-errors, r=oli-obk
matthiaskrgr Feb 9, 2024
f90cac5
Rollup merge of #120828 - nnethercote:fix-stash-steal, r=oli-obk
matthiaskrgr Feb 9, 2024
e0d1c15
Rollup merge of #120831 - Nikokrock:pr/disappearing_startup_objects, …
matthiaskrgr Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,18 @@ impl Duration {
#[must_use]
#[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")]
pub const fn new(secs: u64, nanos: u32) -> Duration {
let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
Some(secs) => secs,
None => panic!("overflow in Duration::new"),
};
let nanos = nanos % NANOS_PER_SEC;
// SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range
Duration { secs, nanos: unsafe { Nanoseconds(nanos) } }
if nanos < NANOS_PER_SEC {
// SAFETY: nanos < NANOS_PER_SEC, therefore nanos is within the valid range
Duration { secs, nanos: unsafe { Nanoseconds(nanos) } }
} else {
let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
Some(secs) => secs,
None => panic!("overflow in Duration::new"),
};
let nanos = nanos % NANOS_PER_SEC;
// SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range
Duration { secs, nanos: unsafe { Nanoseconds(nanos) } }
}
}

/// Creates a new `Duration` from the specified number of whole seconds.
Expand Down