Skip to content

Commit 1db7f69

Browse files
authored
Rollup merge of #103570 - lukas-code:stabilize-ilog, r=scottmcm
Stabilize integer logarithms Stabilizes feature `int_log`. I've also made the functions const stable, because they don't depend on any unstable const features. `rustc_allow_const_fn_unstable` is just there for `Option::expect`, which could be replaced with a `match` and `panic!`. cc ``@rust-lang/wg-const-eval`` closes #70887 (tracking issue) ~~blocked on FCP finishing: #70887 (comment) FCP finished: #70887 (comment)
2 parents 0aaad9e + 9e36fd9 commit 1db7f69

File tree

7 files changed

+36
-34
lines changed

7 files changed

+36
-34
lines changed

library/core/benches/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// wasm32 does not support benches (no time).
22
#![cfg(not(target_arch = "wasm32"))]
33
#![feature(flt2dec)]
4-
#![feature(int_log)]
54
#![feature(test)]
65
#![feature(trusted_random_access)]
76
#![feature(iter_array_chunks)]

library/core/src/num/int_macros.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -2271,15 +2271,16 @@ macro_rules! int_impl {
22712271
/// # Panics
22722272
///
22732273
/// This function will panic if `self` is less than or equal to zero,
2274-
/// or if `base` is less then 2.
2274+
/// or if `base` is less than 2.
22752275
///
22762276
/// # Examples
22772277
///
22782278
/// ```
2279-
/// #![feature(int_log)]
22802279
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
22812280
/// ```
2282-
#[unstable(feature = "int_log", issue = "70887")]
2281+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2282+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2283+
#[rustc_allow_const_fn_unstable(const_option)]
22832284
#[must_use = "this returns the result of the operation, \
22842285
without modifying the original"]
22852286
#[inline]
@@ -2298,10 +2299,11 @@ macro_rules! int_impl {
22982299
/// # Examples
22992300
///
23002301
/// ```
2301-
/// #![feature(int_log)]
23022302
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
23032303
/// ```
2304-
#[unstable(feature = "int_log", issue = "70887")]
2304+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2305+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2306+
#[rustc_allow_const_fn_unstable(const_option)]
23052307
#[must_use = "this returns the result of the operation, \
23062308
without modifying the original"]
23072309
#[inline]
@@ -2319,10 +2321,11 @@ macro_rules! int_impl {
23192321
/// # Example
23202322
///
23212323
/// ```
2322-
/// #![feature(int_log)]
23232324
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
23242325
/// ```
2325-
#[unstable(feature = "int_log", issue = "70887")]
2326+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2327+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2328+
#[rustc_allow_const_fn_unstable(const_option)]
23262329
#[must_use = "this returns the result of the operation, \
23272330
without modifying the original"]
23282331
#[inline]
@@ -2343,10 +2346,10 @@ macro_rules! int_impl {
23432346
/// # Examples
23442347
///
23452348
/// ```
2346-
/// #![feature(int_log)]
23472349
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
23482350
/// ```
2349-
#[unstable(feature = "int_log", issue = "70887")]
2351+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2352+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
23502353
#[must_use = "this returns the result of the operation, \
23512354
without modifying the original"]
23522355
#[inline]
@@ -2379,10 +2382,10 @@ macro_rules! int_impl {
23792382
/// # Examples
23802383
///
23812384
/// ```
2382-
/// #![feature(int_log)]
23832385
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
23842386
/// ```
2385-
#[unstable(feature = "int_log", issue = "70887")]
2387+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2388+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
23862389
#[must_use = "this returns the result of the operation, \
23872390
without modifying the original"]
23882391
#[inline]
@@ -2403,10 +2406,10 @@ macro_rules! int_impl {
24032406
/// # Example
24042407
///
24052408
/// ```
2406-
/// #![feature(int_log)]
24072409
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
24082410
/// ```
2409-
#[unstable(feature = "int_log", issue = "70887")]
2411+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
2412+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
24102413
#[must_use = "this returns the result of the operation, \
24112414
without modifying the original"]
24122415
#[inline]

library/core/src/num/nonzero.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ macro_rules! nonzero_unsigned_operations {
460460
/// # Examples
461461
///
462462
/// ```
463-
/// #![feature(int_log)]
464463
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
465464
///
466465
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().ilog2(), 2);")]
467466
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().ilog2(), 3);")]
468467
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().ilog2(), 3);")]
469468
/// ```
470-
#[unstable(feature = "int_log", issue = "70887")]
469+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
470+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
471471
#[must_use = "this returns the result of the operation, \
472472
without modifying the original"]
473473
#[inline]
@@ -485,14 +485,14 @@ macro_rules! nonzero_unsigned_operations {
485485
/// # Examples
486486
///
487487
/// ```
488-
/// #![feature(int_log)]
489488
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
490489
///
491490
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().ilog10(), 1);")]
492491
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().ilog10(), 2);")]
493492
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().ilog10(), 2);")]
494493
/// ```
495-
#[unstable(feature = "int_log", issue = "70887")]
494+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
495+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
496496
#[must_use = "this returns the result of the operation, \
497497
without modifying the original"]
498498
#[inline]

library/core/src/num/uint_macros.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -692,15 +692,16 @@ macro_rules! uint_impl {
692692
///
693693
/// # Panics
694694
///
695-
/// This function will panic if `self` is zero, or if `base` is less then 2.
695+
/// This function will panic if `self` is zero, or if `base` is less than 2.
696696
///
697697
/// # Examples
698698
///
699699
/// ```
700-
/// #![feature(int_log)]
701700
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
702701
/// ```
703-
#[unstable(feature = "int_log", issue = "70887")]
702+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
703+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
704+
#[rustc_allow_const_fn_unstable(const_option)]
704705
#[must_use = "this returns the result of the operation, \
705706
without modifying the original"]
706707
#[inline]
@@ -719,10 +720,11 @@ macro_rules! uint_impl {
719720
/// # Examples
720721
///
721722
/// ```
722-
/// #![feature(int_log)]
723723
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
724724
/// ```
725-
#[unstable(feature = "int_log", issue = "70887")]
725+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
726+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
727+
#[rustc_allow_const_fn_unstable(const_option)]
726728
#[must_use = "this returns the result of the operation, \
727729
without modifying the original"]
728730
#[inline]
@@ -740,10 +742,11 @@ macro_rules! uint_impl {
740742
/// # Example
741743
///
742744
/// ```
743-
/// #![feature(int_log)]
744745
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
745746
/// ```
746-
#[unstable(feature = "int_log", issue = "70887")]
747+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
748+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
749+
#[rustc_allow_const_fn_unstable(const_option)]
747750
#[must_use = "this returns the result of the operation, \
748751
without modifying the original"]
749752
#[inline]
@@ -764,10 +767,10 @@ macro_rules! uint_impl {
764767
/// # Examples
765768
///
766769
/// ```
767-
/// #![feature(int_log)]
768770
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
769771
/// ```
770-
#[unstable(feature = "int_log", issue = "70887")]
772+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
773+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
771774
#[must_use = "this returns the result of the operation, \
772775
without modifying the original"]
773776
#[inline]
@@ -800,10 +803,10 @@ macro_rules! uint_impl {
800803
/// # Examples
801804
///
802805
/// ```
803-
/// #![feature(int_log)]
804806
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
805807
/// ```
806-
#[unstable(feature = "int_log", issue = "70887")]
808+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
809+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
807810
#[must_use = "this returns the result of the operation, \
808811
without modifying the original"]
809812
#[inline]
@@ -822,10 +825,10 @@ macro_rules! uint_impl {
822825
/// # Examples
823826
///
824827
/// ```
825-
/// #![feature(int_log)]
826828
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
827829
/// ```
828-
#[unstable(feature = "int_log", issue = "70887")]
830+
#[stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
831+
#[rustc_const_stable(feature = "int_log", since = "CURRENT_RUSTC_VERSION")]
829832
#[must_use = "this returns the result of the operation, \
830833
without modifying the original"]
831834
#[inline]

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#![feature(try_trait_v2)]
6565
#![feature(slice_internals)]
6666
#![feature(slice_partition_dedup)]
67-
#![feature(int_log)]
6867
#![feature(iter_advance_by)]
6968
#![feature(iter_array_chunks)]
7069
#![feature(iter_collect_into)]

src/tools/miri/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(never_type)]
44
#![feature(try_blocks)]
55
#![feature(io_error_more)]
6-
#![feature(int_log)]
76
#![feature(variant_count)]
87
#![feature(yeet_expr)]
98
#![feature(is_some_and)]

src/tools/miri/tests/pass/integer-ops.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@compile-flags: -Coverflow-checks=off
2-
#![feature(int_log)]
32
#![allow(arithmetic_overflow)]
43

54
pub fn main() {

0 commit comments

Comments
 (0)