Skip to content

Commit 2008188

Browse files
committed
Auto merge of #107980 - Dylan-DPC:rollup-u4b19bl, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #107654 (reword descriptions of the deprecated int modules) - #107915 (Add `array::map` benchmarks) - #107961 (Avoid copy-pasting the `ilog` panic string in a bunch of places) - #107962 (Add a doc note about why `Chain` is not `ExactSizeIterator`) - #107966 (Update browser-ui-test version to 0.14.3) - #107970 (Hermit: Remove floor symbol) - #107973 (Fix unintentional UB in SIMD tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 96834f0 + 4bf5808 commit 2008188

File tree

24 files changed

+152
-175
lines changed

24 files changed

+152
-175
lines changed

library/core/benches/array.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use test::black_box;
2+
use test::Bencher;
3+
4+
macro_rules! map_array {
5+
($func_name:ident, $start_item: expr, $map_item: expr, $arr_size: expr) => {
6+
#[bench]
7+
fn $func_name(b: &mut Bencher) {
8+
let arr = [$start_item; $arr_size];
9+
b.iter(|| black_box(arr).map(|_| black_box($map_item)));
10+
}
11+
};
12+
}
13+
14+
map_array!(map_8byte_8byte_8, 0u64, 1u64, 800);
15+
map_array!(map_8byte_8byte_64, 0u64, 1u64, 6400);
16+
map_array!(map_8byte_8byte_256, 0u64, 1u64, 25600);
17+
18+
map_array!(map_8byte_256byte_256, 0u64, [0u64; 4], 25600);
19+
map_array!(map_256byte_8byte_256, [0u64; 4], 0u64, 25600);

library/core/benches/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
extern crate test;
1010

1111
mod any;
12+
mod array;
1213
mod ascii;
1314
mod char;
1415
mod fmt;

library/core/src/iter/traits/exact_size.rs

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
///
2222
/// [`len`]: ExactSizeIterator::len
2323
///
24+
/// # When *shouldn't* an adapter be `ExactSizeIterator`?
25+
///
26+
/// If an adapter makes an iterator *longer*, then it's usually incorrect for
27+
/// that adapter to implement `ExactSizeIterator`. The inner exact-sized
28+
/// iterator might already be `usize::MAX`-long, and thus the length of the
29+
/// longer adapted iterator would no longer be exactly representable in `usize`.
30+
///
31+
/// This is why [`Chain<A, B>`](crate::iter::Chain) isn't `ExactSizeIterator`,
32+
/// even when `A` and `B` are both `ExactSizeIterator`.
33+
///
2434
/// # Examples
2535
///
2636
/// Basic usage:

library/core/src/iter/traits/marker.rs

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ impl<I: FusedIterator + ?Sized> FusedIterator for &mut I {}
3131
/// The iterator must produce exactly the number of elements it reported
3232
/// or diverge before reaching the end.
3333
///
34+
/// # When *shouldn't* an adapter be `TrustedLen`?
35+
///
36+
/// If an adapter makes an iterator *shorter* by a given amount, then it's
37+
/// usually incorrect for that adapter to implement `TrustedLen`. The inner
38+
/// iterator might return more than `usize::MAX` items, but there's no way to
39+
/// know what `k` elements less than that will be, since the `size_hint` from
40+
/// the inner iterator has already saturated and lost that information.
41+
///
42+
/// This is why [`Skip<I>`](crate::iter::Skip) isn't `TrustedLen`, even when
43+
/// `I` implements `TrustedLen`.
44+
///
3445
/// # Safety
3546
///
3647
/// This trait must only be implemented when the contract is upheld. Consumers

library/core/src/num/int_log10.rs

+8
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,11 @@ pub const fn i64(val: i64) -> u32 {
138138
pub const fn i128(val: i128) -> u32 {
139139
u128(val as u128)
140140
}
141+
142+
/// Instantiate this panic logic once, rather than for all the ilog methods
143+
/// on every single primitive type.
144+
#[cold]
145+
#[track_caller]
146+
pub const fn panic_for_nonpositive_argument() -> ! {
147+
panic!("argument of integer logarithm must be positive")
148+
}

library/core/src/num/int_macros.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -2331,14 +2331,17 @@ macro_rules! int_impl {
23312331
/// ```
23322332
#[stable(feature = "int_log", since = "1.67.0")]
23332333
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
2334-
#[rustc_allow_const_fn_unstable(const_option)]
23352334
#[must_use = "this returns the result of the operation, \
23362335
without modifying the original"]
23372336
#[inline]
23382337
#[track_caller]
23392338
pub const fn ilog(self, base: Self) -> u32 {
23402339
assert!(base >= 2, "base of integer logarithm must be at least 2");
2341-
self.checked_ilog(base).expect("argument of integer logarithm must be positive")
2340+
if let Some(log) = self.checked_ilog(base) {
2341+
log
2342+
} else {
2343+
int_log10::panic_for_nonpositive_argument()
2344+
}
23422345
}
23432346

23442347
/// Returns the base 2 logarithm of the number, rounded down.
@@ -2354,13 +2357,16 @@ macro_rules! int_impl {
23542357
/// ```
23552358
#[stable(feature = "int_log", since = "1.67.0")]
23562359
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
2357-
#[rustc_allow_const_fn_unstable(const_option)]
23582360
#[must_use = "this returns the result of the operation, \
23592361
without modifying the original"]
23602362
#[inline]
23612363
#[track_caller]
23622364
pub const fn ilog2(self) -> u32 {
2363-
self.checked_ilog2().expect("argument of integer logarithm must be positive")
2365+
if let Some(log) = self.checked_ilog2() {
2366+
log
2367+
} else {
2368+
int_log10::panic_for_nonpositive_argument()
2369+
}
23642370
}
23652371

23662372
/// Returns the base 10 logarithm of the number, rounded down.
@@ -2376,13 +2382,16 @@ macro_rules! int_impl {
23762382
/// ```
23772383
#[stable(feature = "int_log", since = "1.67.0")]
23782384
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
2379-
#[rustc_allow_const_fn_unstable(const_option)]
23802385
#[must_use = "this returns the result of the operation, \
23812386
without modifying the original"]
23822387
#[inline]
23832388
#[track_caller]
23842389
pub const fn ilog10(self) -> u32 {
2385-
self.checked_ilog10().expect("argument of integer logarithm must be positive")
2390+
if let Some(log) = self.checked_ilog10() {
2391+
log
2392+
} else {
2393+
int_log10::panic_for_nonpositive_argument()
2394+
}
23862395
}
23872396

23882397
/// Returns the logarithm of the number with respect to an arbitrary base,

library/core/src/num/shells/i128.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 128-bit signed integer type.
2-
//!
3-
//! *[See also the `i128` primitive type][i128].*
1+
//! Redundant constants module for the [`i128` primitive type][i128].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/i16.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 16-bit signed integer type.
2-
//!
3-
//! *[See also the `i16` primitive type][i16].*
1+
//! Redundant constants module for the [`i16` primitive type][i16].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/i32.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 32-bit signed integer type.
2-
//!
3-
//! *[See also the `i32` primitive type][i32].*
1+
//! Redundant constants module for the [`i32` primitive type][i32].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/i64.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 64-bit signed integer type.
2-
//!
3-
//! *[See also the `i64` primitive type][i64].*
1+
//! Redundant constants module for the [`i64` primitive type][i64].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/i8.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 8-bit signed integer type.
2-
//!
3-
//! *[See also the `i8` primitive type][i8].*
1+
//! Redundant constants module for the [`i8` primitive type][i8].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/isize.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the pointer-sized signed integer type.
2-
//!
3-
//! *[See also the `isize` primitive type][isize].*
1+
//! Redundant constants module for the [`isize` primitive type][isize].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/u128.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 128-bit unsigned integer type.
2-
//!
3-
//! *[See also the `u128` primitive type][u128].*
1+
//! Redundant constants module for the [`u128` primitive type][u128].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/u16.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 16-bit unsigned integer type.
2-
//!
3-
//! *[See also the `u16` primitive type][u16].*
1+
//! Redundant constants module for the [`i16` primitive type][i16].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/u32.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 32-bit unsigned integer type.
2-
//!
3-
//! *[See also the `u32` primitive type][u32].*
1+
//! Redundant constants module for the [`u32` primitive type][u32].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/u64.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 64-bit unsigned integer type.
2-
//!
3-
//! *[See also the `u64` primitive type][u64].*
1+
//! Redundant constants module for the [`u64` primitive type][u64].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/u8.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the 8-bit unsigned integer type.
2-
//!
3-
//! *[See also the `u8` primitive type][u8].*
1+
//! Redundant constants module for the [`u8` primitive type][u8].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/shells/usize.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
//! Constants for the pointer-sized unsigned integer type.
2-
//!
3-
//! *[See also the `usize` primitive type][usize].*
1+
//! Redundant constants module for the [`usize` primitive type][usize].
42
//!
53
//! New code should use the associated constants directly on the primitive type.
64

library/core/src/num/uint_macros.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,17 @@ macro_rules! uint_impl {
705705
/// ```
706706
#[stable(feature = "int_log", since = "1.67.0")]
707707
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
708-
#[rustc_allow_const_fn_unstable(const_option)]
709708
#[must_use = "this returns the result of the operation, \
710709
without modifying the original"]
711710
#[inline]
712711
#[track_caller]
713712
pub const fn ilog(self, base: Self) -> u32 {
714713
assert!(base >= 2, "base of integer logarithm must be at least 2");
715-
self.checked_ilog(base).expect("argument of integer logarithm must be positive")
714+
if let Some(log) = self.checked_ilog(base) {
715+
log
716+
} else {
717+
int_log10::panic_for_nonpositive_argument()
718+
}
716719
}
717720

718721
/// Returns the base 2 logarithm of the number, rounded down.
@@ -728,13 +731,16 @@ macro_rules! uint_impl {
728731
/// ```
729732
#[stable(feature = "int_log", since = "1.67.0")]
730733
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
731-
#[rustc_allow_const_fn_unstable(const_option)]
732734
#[must_use = "this returns the result of the operation, \
733735
without modifying the original"]
734736
#[inline]
735737
#[track_caller]
736738
pub const fn ilog2(self) -> u32 {
737-
self.checked_ilog2().expect("argument of integer logarithm must be positive")
739+
if let Some(log) = self.checked_ilog2() {
740+
log
741+
} else {
742+
int_log10::panic_for_nonpositive_argument()
743+
}
738744
}
739745

740746
/// Returns the base 10 logarithm of the number, rounded down.
@@ -750,13 +756,16 @@ macro_rules! uint_impl {
750756
/// ```
751757
#[stable(feature = "int_log", since = "1.67.0")]
752758
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
753-
#[rustc_allow_const_fn_unstable(const_option)]
754759
#[must_use = "this returns the result of the operation, \
755760
without modifying the original"]
756761
#[inline]
757762
#[track_caller]
758763
pub const fn ilog10(self) -> u32 {
759-
self.checked_ilog10().expect("argument of integer logarithm must be positive")
764+
if let Some(log) = self.checked_ilog10() {
765+
log
766+
} else {
767+
int_log10::panic_for_nonpositive_argument()
768+
}
760769
}
761770

762771
/// Returns the logarithm of the number with respect to an arbitrary base,

library/std/src/sys/hermit/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ pub fn unsupported_err() -> crate::io::Error {
7272
)
7373
}
7474

75-
#[no_mangle]
76-
pub extern "C" fn floor(x: f64) -> f64 {
77-
unsafe { intrinsics::floorf64(x) }
78-
}
79-
8075
pub fn abort_internal() -> ! {
8176
unsafe {
8277
abi::abort();
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.1
1+
0.14.3

0 commit comments

Comments
 (0)