Skip to content

Commit 37faf5d

Browse files
committed
Auto merge of rust-lang#91288 - matthiaskrgr:rollup-yp5h41r, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#83791 (Weaken guarantee around advancing underlying iterators in zip) - rust-lang#90995 (Document non-guarantees for Hash) - rust-lang#91057 (Expand `available_parallelism` docs in anticipation of cgroup quota support) - rust-lang#91062 (rustdoc: Consolidate static-file replacement mechanism) - rust-lang#91208 (Account for incorrect `where T::Assoc = Ty` bound) - rust-lang#91266 (Use non-generic inner function for pointer formatting) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d78dc06 + fa9ef5f commit 37faf5d

File tree

4 files changed

+47
-23
lines changed

4 files changed

+47
-23
lines changed

core/src/fmt/mod.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,28 +2186,34 @@ impl Display for char {
21862186
#[stable(feature = "rust1", since = "1.0.0")]
21872187
impl<T: ?Sized> Pointer for *const T {
21882188
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
2189-
let old_width = f.width;
2190-
let old_flags = f.flags;
2191-
2192-
// The alternate flag is already treated by LowerHex as being special-
2193-
// it denotes whether to prefix with 0x. We use it to work out whether
2194-
// or not to zero extend, and then unconditionally set it to get the
2195-
// prefix.
2196-
if f.alternate() {
2197-
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);
2198-
2199-
if f.width.is_none() {
2200-
f.width = Some((usize::BITS / 4) as usize + 2);
2189+
/// Since the formatting will be identical for all pointer types, use a non-monomorphized
2190+
/// implementation for the actual formatting to reduce the amount of codegen work needed
2191+
fn inner(ptr: *const (), f: &mut Formatter<'_>) -> Result {
2192+
let old_width = f.width;
2193+
let old_flags = f.flags;
2194+
2195+
// The alternate flag is already treated by LowerHex as being special-
2196+
// it denotes whether to prefix with 0x. We use it to work out whether
2197+
// or not to zero extend, and then unconditionally set it to get the
2198+
// prefix.
2199+
if f.alternate() {
2200+
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);
2201+
2202+
if f.width.is_none() {
2203+
f.width = Some((usize::BITS / 4) as usize + 2);
2204+
}
22012205
}
2202-
}
2203-
f.flags |= 1 << (FlagV1::Alternate as u32);
2206+
f.flags |= 1 << (FlagV1::Alternate as u32);
2207+
2208+
let ret = LowerHex::fmt(&(ptr as usize), f);
22042209

2205-
let ret = LowerHex::fmt(&(*self as *const () as usize), f);
2210+
f.width = old_width;
2211+
f.flags = old_flags;
22062212

2207-
f.width = old_width;
2208-
f.flags = old_flags;
2213+
ret
2214+
}
22092215

2210-
ret
2216+
inner(*self as *const (), f)
22112217
}
22122218
}
22132219

core/src/hash/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ mod sip;
164164
/// `0xFF` byte to the `Hasher` so that the values `("ab", "c")` and `("a",
165165
/// "bc")` hash differently.
166166
///
167+
/// ## Portability
168+
///
169+
/// Due to differences in endianness and type sizes, data fed by `Hash` to a `Hasher`
170+
/// should not be considered portable across platforms. Additionally the data passed by most
171+
/// standard library types should not be considered stable between compiler versions.
172+
///
173+
/// This means tests shouldn't probe hard-coded hash values or data fed to a `Hasher` and
174+
/// instead should check consistency with `Eq`.
175+
///
176+
/// Serialization formats intended to be portable between platforms or compiler versions should
177+
/// either avoid encoding hashes or only rely on `Hash` and `Hasher` implementations that
178+
/// provide additional guarantees.
179+
///
167180
/// [`HashMap`]: ../../std/collections/struct.HashMap.html
168181
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
169182
/// [`hash`]: Hash::hash

core/src/iter/traits/iterator.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ pub trait Iterator {
458458
/// In other words, it zips two iterators together, into a single one.
459459
///
460460
/// If either iterator returns [`None`], [`next`] from the zipped iterator
461-
/// will return [`None`]. If the first iterator returns [`None`], `zip` will
462-
/// short-circuit and `next` will not be called on the second iterator.
461+
/// will return [`None`].
462+
/// If the zipped iterator has no more elements to return then each further attempt to advance
463+
/// it will first try to advance the first iterator at most one time and if it still yielded an item
464+
/// try to advance the second iterator at most one time.
463465
///
464466
/// # Examples
465467
///

std/src/thread/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,9 +1460,12 @@ fn _assert_sync_and_send() {
14601460
/// The purpose of this API is to provide an easy and portable way to query
14611461
/// the default amount of parallelism the program should use. Among other things it
14621462
/// does not expose information on NUMA regions, does not account for
1463-
/// differences in (co)processor capabilities, and will not modify the program's
1464-
/// global state in order to more accurately query the amount of available
1465-
/// parallelism.
1463+
/// differences in (co)processor capabilities or current system load,
1464+
/// and will not modify the program's global state in order to more accurately
1465+
/// query the amount of available parallelism.
1466+
///
1467+
/// Where both fixed steady-state and burst limits are available the steady-state
1468+
/// capacity will be used to ensure more predictable latencies.
14661469
///
14671470
/// Resource limits can be changed during the runtime of a program, therefore the value is
14681471
/// not cached and instead recomputed every time this function is called. It should not be

0 commit comments

Comments
 (0)