Skip to content

Commit 1088317

Browse files
authored
Rollup merge of rust-lang#71796 - RalfJung:from-secs, r=nikomatsakis
de-promote Duration::from_secs In rust-lang#67531, we removed the `rustc_promotable` attribute from a bunch of `Duration` methods, but not from `Duration::from_secs`. This makes the current list of promotable functions the following (courtesy of @ecstatic-morse): * `INT::min_value`, `INT::max_value` * `std::mem::size_of`, `std::mem::align_of` * `RangeInclusive::new` (backing `x..=y`) * `std::ptr::null`, `std::ptr::null_mut` * `RawWaker::new`, `RawWakerVTable::new` ??? * `Duration::from_secs` I feel like the last one stands out a bit here -- the rest are all very core language primitives, and `RawWaker` has a strong motivation for getting a `'static` vtable. But a `&'static Duration`? That seems unlikely. So I propose we no longer promote calls to `Duration::from_secs`, which is what this PR does. rust-lang#67531 saw zero regressions and I am not aware of anyone complaining that this broke their (non-cratered) code, so I consider it likely the same will be true here, but of course we'd do a crater run. See [this document](https://github.com/rust-lang/const-eval/blob/master/promotion.md) for some more background on promotion and rust-lang/const-eval#19 for some of the concerns around promoting function calls.
2 parents 826cb06 + 58ae4a9 commit 1088317

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

src/libcore/time.rs

-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ impl Duration {
152152
/// ```
153153
#[stable(feature = "duration", since = "1.3.0")]
154154
#[inline]
155-
#[rustc_promotable]
156155
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
157156
pub const fn from_secs(secs: u64) -> Duration {
158157
Duration { secs, nanos: 0 }

0 commit comments

Comments
 (0)