Skip to content

Commit

Permalink
Auto merge of rust-lang#107980 - Dylan-DPC:rollup-u4b19bl, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#107654 (reword descriptions of the deprecated int modules)
 - rust-lang#107915 (Add `array::map` benchmarks)
 - rust-lang#107961 (Avoid copy-pasting the `ilog` panic string in a bunch of places)
 - rust-lang#107962 (Add a doc note about why `Chain` is not `ExactSizeIterator`)
 - rust-lang#107966 (Update browser-ui-test version to 0.14.3)
 - rust-lang#107970 (Hermit: Remove floor symbol)
 - rust-lang#107973 (Fix unintentional UB in SIMD tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 13, 2023
2 parents 96834f0 + 4bf5808 commit 2008188
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 175 deletions.
19 changes: 19 additions & 0 deletions library/core/benches/array.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use test::black_box;
use test::Bencher;

macro_rules! map_array {
($func_name:ident, $start_item: expr, $map_item: expr, $arr_size: expr) => {
#[bench]
fn $func_name(b: &mut Bencher) {
let arr = [$start_item; $arr_size];
b.iter(|| black_box(arr).map(|_| black_box($map_item)));
}
};
}

map_array!(map_8byte_8byte_8, 0u64, 1u64, 800);
map_array!(map_8byte_8byte_64, 0u64, 1u64, 6400);
map_array!(map_8byte_8byte_256, 0u64, 1u64, 25600);

map_array!(map_8byte_256byte_256, 0u64, [0u64; 4], 25600);
map_array!(map_256byte_8byte_256, [0u64; 4], 0u64, 25600);
1 change: 1 addition & 0 deletions library/core/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
extern crate test;

mod any;
mod array;
mod ascii;
mod char;
mod fmt;
Expand Down
10 changes: 10 additions & 0 deletions library/core/src/iter/traits/exact_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
///
/// [`len`]: ExactSizeIterator::len
///
/// # When *shouldn't* an adapter be `ExactSizeIterator`?
///
/// If an adapter makes an iterator *longer*, then it's usually incorrect for
/// that adapter to implement `ExactSizeIterator`. The inner exact-sized
/// iterator might already be `usize::MAX`-long, and thus the length of the
/// longer adapted iterator would no longer be exactly representable in `usize`.
///
/// This is why [`Chain<A, B>`](crate::iter::Chain) isn't `ExactSizeIterator`,
/// even when `A` and `B` are both `ExactSizeIterator`.
///
/// # Examples
///
/// Basic usage:
Expand Down
11 changes: 11 additions & 0 deletions library/core/src/iter/traits/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ impl<I: FusedIterator + ?Sized> FusedIterator for &mut I {}
/// The iterator must produce exactly the number of elements it reported
/// or diverge before reaching the end.
///
/// # When *shouldn't* an adapter be `TrustedLen`?
///
/// If an adapter makes an iterator *shorter* by a given amount, then it's
/// usually incorrect for that adapter to implement `TrustedLen`. The inner
/// iterator might return more than `usize::MAX` items, but there's no way to
/// know what `k` elements less than that will be, since the `size_hint` from
/// the inner iterator has already saturated and lost that information.
///
/// This is why [`Skip<I>`](crate::iter::Skip) isn't `TrustedLen`, even when
/// `I` implements `TrustedLen`.
///
/// # Safety
///
/// This trait must only be implemented when the contract is upheld. Consumers
Expand Down
8 changes: 8 additions & 0 deletions library/core/src/num/int_log10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ pub const fn i64(val: i64) -> u32 {
pub const fn i128(val: i128) -> u32 {
u128(val as u128)
}

/// Instantiate this panic logic once, rather than for all the ilog methods
/// on every single primitive type.
#[cold]
#[track_caller]
pub const fn panic_for_nonpositive_argument() -> ! {
panic!("argument of integer logarithm must be positive")
}
21 changes: 15 additions & 6 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2331,14 +2331,17 @@ macro_rules! int_impl {
/// ```
#[stable(feature = "int_log", since = "1.67.0")]
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn ilog(self, base: Self) -> u32 {
assert!(base >= 2, "base of integer logarithm must be at least 2");
self.checked_ilog(base).expect("argument of integer logarithm must be positive")
if let Some(log) = self.checked_ilog(base) {
log
} else {
int_log10::panic_for_nonpositive_argument()
}
}

/// Returns the base 2 logarithm of the number, rounded down.
Expand All @@ -2354,13 +2357,16 @@ macro_rules! int_impl {
/// ```
#[stable(feature = "int_log", since = "1.67.0")]
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn ilog2(self) -> u32 {
self.checked_ilog2().expect("argument of integer logarithm must be positive")
if let Some(log) = self.checked_ilog2() {
log
} else {
int_log10::panic_for_nonpositive_argument()
}
}

/// Returns the base 10 logarithm of the number, rounded down.
Expand All @@ -2376,13 +2382,16 @@ macro_rules! int_impl {
/// ```
#[stable(feature = "int_log", since = "1.67.0")]
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn ilog10(self) -> u32 {
self.checked_ilog10().expect("argument of integer logarithm must be positive")
if let Some(log) = self.checked_ilog10() {
log
} else {
int_log10::panic_for_nonpositive_argument()
}
}

/// Returns the logarithm of the number with respect to an arbitrary base,
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/i128.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 128-bit signed integer type.
//!
//! *[See also the `i128` primitive type][i128].*
//! Redundant constants module for the [`i128` primitive type][i128].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/i16.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 16-bit signed integer type.
//!
//! *[See also the `i16` primitive type][i16].*
//! Redundant constants module for the [`i16` primitive type][i16].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/i32.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 32-bit signed integer type.
//!
//! *[See also the `i32` primitive type][i32].*
//! Redundant constants module for the [`i32` primitive type][i32].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/i64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 64-bit signed integer type.
//!
//! *[See also the `i64` primitive type][i64].*
//! Redundant constants module for the [`i64` primitive type][i64].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/i8.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 8-bit signed integer type.
//!
//! *[See also the `i8` primitive type][i8].*
//! Redundant constants module for the [`i8` primitive type][i8].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/isize.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the pointer-sized signed integer type.
//!
//! *[See also the `isize` primitive type][isize].*
//! Redundant constants module for the [`isize` primitive type][isize].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/u128.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 128-bit unsigned integer type.
//!
//! *[See also the `u128` primitive type][u128].*
//! Redundant constants module for the [`u128` primitive type][u128].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/u16.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 16-bit unsigned integer type.
//!
//! *[See also the `u16` primitive type][u16].*
//! Redundant constants module for the [`i16` primitive type][i16].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/u32.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 32-bit unsigned integer type.
//!
//! *[See also the `u32` primitive type][u32].*
//! Redundant constants module for the [`u32` primitive type][u32].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/u64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 64-bit unsigned integer type.
//!
//! *[See also the `u64` primitive type][u64].*
//! Redundant constants module for the [`u64` primitive type][u64].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/u8.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the 8-bit unsigned integer type.
//!
//! *[See also the `u8` primitive type][u8].*
//! Redundant constants module for the [`u8` primitive type][u8].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
4 changes: 1 addition & 3 deletions library/core/src/num/shells/usize.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Constants for the pointer-sized unsigned integer type.
//!
//! *[See also the `usize` primitive type][usize].*
//! Redundant constants module for the [`usize` primitive type][usize].
//!
//! New code should use the associated constants directly on the primitive type.
Expand Down
21 changes: 15 additions & 6 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,17 @@ macro_rules! uint_impl {
/// ```
#[stable(feature = "int_log", since = "1.67.0")]
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn ilog(self, base: Self) -> u32 {
assert!(base >= 2, "base of integer logarithm must be at least 2");
self.checked_ilog(base).expect("argument of integer logarithm must be positive")
if let Some(log) = self.checked_ilog(base) {
log
} else {
int_log10::panic_for_nonpositive_argument()
}
}

/// Returns the base 2 logarithm of the number, rounded down.
Expand All @@ -728,13 +731,16 @@ macro_rules! uint_impl {
/// ```
#[stable(feature = "int_log", since = "1.67.0")]
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn ilog2(self) -> u32 {
self.checked_ilog2().expect("argument of integer logarithm must be positive")
if let Some(log) = self.checked_ilog2() {
log
} else {
int_log10::panic_for_nonpositive_argument()
}
}

/// Returns the base 10 logarithm of the number, rounded down.
Expand All @@ -750,13 +756,16 @@ macro_rules! uint_impl {
/// ```
#[stable(feature = "int_log", since = "1.67.0")]
#[rustc_const_stable(feature = "int_log", since = "1.67.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[track_caller]
pub const fn ilog10(self) -> u32 {
self.checked_ilog10().expect("argument of integer logarithm must be positive")
if let Some(log) = self.checked_ilog10() {
log
} else {
int_log10::panic_for_nonpositive_argument()
}
}

/// Returns the logarithm of the number with respect to an arbitrary base,
Expand Down
5 changes: 0 additions & 5 deletions library/std/src/sys/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ pub fn unsupported_err() -> crate::io::Error {
)
}

#[no_mangle]
pub extern "C" fn floor(x: f64) -> f64 {
unsafe { intrinsics::floorf64(x) }
}

pub fn abort_internal() -> ! {
unsafe {
abi::abort();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.1
0.14.3
Loading

0 comments on commit 2008188

Please sign in to comment.