Skip to content

Commit 85576a8

Browse files
The Miri Cronjob Botgitbot
The Miri Cronjob Bot
authored and
gitbot
committed
Merge from rustc
2 parents 682595d + e72e22d commit 85576a8

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

core/src/hint.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,11 @@ pub fn spin_loop() {
468468
/// // No assumptions can be made about either operand, so the multiplication is not optimized out.
469469
/// let y = black_box(5) * black_box(10);
470470
/// ```
471+
///
472+
/// During constant evaluation, `black_box` is treated as a no-op.
471473
#[inline]
472474
#[stable(feature = "bench_black_box", since = "1.66.0")]
473-
#[rustc_const_unstable(feature = "const_black_box", issue = "none")]
475+
#[rustc_const_stable(feature = "const_black_box", since = "CURRENT_RUSTC_VERSION")]
474476
pub const fn black_box<T>(dummy: T) -> T {
475477
crate::intrinsics::black_box(dummy)
476478
}

core/src/intrinsics/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3725,6 +3725,7 @@ pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: u
37253725
#[rustc_nounwind]
37263726
#[rustc_intrinsic]
37273727
#[rustc_intrinsic_must_be_overridden]
3728+
#[rustc_intrinsic_const_stable_indirect]
37283729
pub const fn black_box<T>(_dummy: T) -> T {
37293730
unimplemented!()
37303731
}

core/src/panicking.rs

+16
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,22 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
291291
)
292292
}
293293

294+
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold, optimize(size))]
295+
#[cfg_attr(feature = "panic_immediate_abort", inline)]
296+
#[track_caller]
297+
#[cfg_attr(not(bootstrap), lang = "panic_null_pointer_dereference")] // needed by codegen for panic on null pointer deref
298+
#[rustc_nounwind] // `CheckNull` MIR pass requires this function to never unwind
299+
fn panic_null_pointer_dereference() -> ! {
300+
if cfg!(feature = "panic_immediate_abort") {
301+
super::intrinsics::abort()
302+
}
303+
304+
panic_nounwind_fmt(
305+
format_args!("null pointer dereference occured"),
306+
/* force_no_backtrace */ false,
307+
)
308+
}
309+
294310
/// Panics because we cannot unwind out of a function.
295311
///
296312
/// This is a separate function to avoid the codesize impact of each crate containing the string to

core/src/sync/atomic.rs

+18
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,12 @@ impl AtomicBool {
716716
/// AcqRel | AcqRel | Acquire
717717
/// SeqCst | SeqCst | SeqCst
718718
///
719+
/// `compare_and_swap` and `compare_exchange` also differ in their return type. You can use
720+
/// `compare_exchange(...).unwrap_or_else(|x| x)` to recover the behavior of `compare_and_swap`,
721+
/// but in most cases it is more idiomatic to check whether the return value is `Ok` or `Err`
722+
/// rather than to infer success vs failure based on the value that was read.
723+
///
724+
/// During migration, consider whether it makes sense to use `compare_exchange_weak` instead.
719725
/// `compare_exchange_weak` is allowed to fail spuriously even when the comparison succeeds,
720726
/// which allows the compiler to generate better assembly code when the compare and swap
721727
/// is used in a loop.
@@ -1651,6 +1657,12 @@ impl<T> AtomicPtr<T> {
16511657
/// AcqRel | AcqRel | Acquire
16521658
/// SeqCst | SeqCst | SeqCst
16531659
///
1660+
/// `compare_and_swap` and `compare_exchange` also differ in their return type. You can use
1661+
/// `compare_exchange(...).unwrap_or_else(|x| x)` to recover the behavior of `compare_and_swap`,
1662+
/// but in most cases it is more idiomatic to check whether the return value is `Ok` or `Err`
1663+
/// rather than to infer success vs failure based on the value that was read.
1664+
///
1665+
/// During migration, consider whether it makes sense to use `compare_exchange_weak` instead.
16541666
/// `compare_exchange_weak` is allowed to fail spuriously even when the comparison succeeds,
16551667
/// which allows the compiler to generate better assembly code when the compare and swap
16561668
/// is used in a loop.
@@ -2771,6 +2783,12 @@ macro_rules! atomic_int {
27712783
/// AcqRel | AcqRel | Acquire
27722784
/// SeqCst | SeqCst | SeqCst
27732785
///
2786+
/// `compare_and_swap` and `compare_exchange` also differ in their return type. You can use
2787+
/// `compare_exchange(...).unwrap_or_else(|x| x)` to recover the behavior of `compare_and_swap`,
2788+
/// but in most cases it is more idiomatic to check whether the return value is `Ok` or `Err`
2789+
/// rather than to infer success vs failure based on the value that was read.
2790+
///
2791+
/// During migration, consider whether it makes sense to use `compare_exchange_weak` instead.
27742792
/// `compare_exchange_weak` is allowed to fail spuriously even when the comparison succeeds,
27752793
/// which allows the compiler to generate better assembly code when the compare and swap
27762794
/// is used in a loop.

coretests/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(bstr)]
1515
#![feature(cell_update)]
1616
#![feature(clone_to_uninit)]
17-
#![feature(const_black_box)]
1817
#![feature(const_eval_select)]
1918
#![feature(const_swap_nonoverlapping)]
2019
#![feature(const_trait_impl)]

0 commit comments

Comments
 (0)