Skip to content

Commit 60d6184

Browse files
borsgitbot
authored and
gitbot
committed
Auto merge of rust-lang#136332 - jhpratt:rollup-aa69d0e, r=jhpratt
Rollup of 9 pull requests Successful merges: - rust-lang#132156 (When encountering unexpected closure return type, point at return type/expression) - rust-lang#133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle) - rust-lang#136281 (`rustc_hir_analysis` cleanups) - rust-lang#136297 (Fix a typo in profile-guided-optimization.md) - rust-lang#136300 (atomic: extend compare_and_swap migration docs) - rust-lang#136310 (normalize `*.long-type.txt` paths for compare-mode tests) - rust-lang#136312 (Disable `overflow_delimited_expr` in edition 2024) - rust-lang#136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics) - rust-lang#136323 (Fix a typo in conventions.md) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6b47569 + 0dce309 commit 60d6184

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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.

0 commit comments

Comments
 (0)