diff --git a/compiler/rustc_error_messages/locales/en-US/lint.ftl b/compiler/rustc_error_messages/locales/en-US/lint.ftl index e7e07093c0324..55e96e58e4688 100644 --- a/compiler/rustc_error_messages/locales/en-US/lint.ftl +++ b/compiler/rustc_error_messages/locales/en-US/lint.ftl @@ -247,11 +247,6 @@ lint-atomic-ordering-invalid = `{$method}`'s failure ordering may not be `Releas .label = invalid failure ordering .help = consider using `Acquire` or `Relaxed` failure ordering instead -lint-atomic-ordering-invalid-fail-success = `{$method}`'s success ordering must be at least as strong as its failure ordering - .fail-label = `{$fail_ordering}` failure ordering - .success-label = `{$success_ordering}` success ordering - .suggestion = consider using `{$success_suggestion}` success ordering instead - lint-unused-op = unused {$op} that must be used .label = the {$op} produces a value .suggestion = use `let _ = ...` to ignore the resulting value diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index aca481df2e113..5c07afeb7aa8f 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1434,10 +1434,6 @@ declare_lint! { /// - Passing `Ordering::Release` or `Ordering::AcqRel` as the failure /// ordering for any of `AtomicType::compare_exchange`, /// `AtomicType::compare_exchange_weak`, or `AtomicType::fetch_update`. - /// - /// - Passing in a pair of orderings to `AtomicType::compare_exchange`, - /// `AtomicType::compare_exchange_weak`, or `AtomicType::fetch_update` - /// where the failure ordering is stronger than the success ordering. INVALID_ATOMIC_ORDERING, Deny, "usage of invalid atomic ordering in atomic operations and memory fences" @@ -1544,9 +1540,9 @@ impl InvalidAtomicOrdering { let Some((method, args)) = Self::inherent_atomic_method_call(cx, expr, &[sym::fetch_update, sym::compare_exchange, sym::compare_exchange_weak]) else {return }; - let (success_order_arg, fail_order_arg) = match method { - sym::fetch_update => (&args[1], &args[2]), - sym::compare_exchange | sym::compare_exchange_weak => (&args[3], &args[4]), + let fail_order_arg = match method { + sym::fetch_update => &args[2], + sym::compare_exchange | sym::compare_exchange_weak => &args[4], _ => return, }; @@ -1568,37 +1564,6 @@ impl InvalidAtomicOrdering { InvalidAtomicOrderingDiag { method, fail_order_arg_span: fail_order_arg.span }, ); } - - let Some(success_ordering) = Self::match_ordering(cx, success_order_arg) else { return }; - - if matches!( - (success_ordering, fail_ordering), - (sym::Relaxed | sym::Release, sym::Acquire) - | (sym::Relaxed | sym::Release | sym::Acquire | sym::AcqRel, sym::SeqCst) - ) { - let success_suggestion = - if success_ordering == sym::Release && fail_ordering == sym::Acquire { - sym::AcqRel - } else { - fail_ordering - }; - cx.struct_span_lint(INVALID_ATOMIC_ORDERING, success_order_arg.span, |diag| { - diag.build(fluent::lint::atomic_ordering_invalid_fail_success) - .set_arg("method", method) - .set_arg("fail_ordering", fail_ordering) - .set_arg("success_ordering", success_ordering) - .set_arg("success_suggestion", success_suggestion) - .span_label(fail_order_arg.span, fluent::lint::fail_label) - .span_label(success_order_arg.span, fluent::lint::success_label) - .span_suggestion_short( - success_order_arg.span, - fluent::lint::suggestion, - format!("std::sync::atomic::Ordering::{success_suggestion}"), - Applicability::MaybeIncorrect, - ) - .emit(); - }); - } } } diff --git a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.rs b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.rs index 0e0d604ae046d..63204c725c3dc 100644 --- a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.rs +++ b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.rs @@ -9,11 +9,17 @@ fn main() { // Allowed ordering combos let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Relaxed); - let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Acquire); + let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Acquire); + let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::SeqCst); let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Relaxed); + let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Acquire); + let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::SeqCst); let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering::Relaxed); - let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Acquire); + let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::Acquire); + let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::SeqCst); let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Relaxed); + let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Acquire); + let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::SeqCst); let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Relaxed); let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Acquire); let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::SeqCst); @@ -41,22 +47,4 @@ fn main() { //~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel` let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Release); //~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel` - - // Release success order forbids failure order of Acquire or SeqCst - let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::Acquire); - //~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as - let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::SeqCst); - //~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as - - // Relaxed success order also forbids failure order of Acquire or SeqCst - let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::SeqCst); - //~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as - let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Acquire); - //~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as - - // Acquire/AcqRel forbids failure order of SeqCst - let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::SeqCst); - //~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as - let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::SeqCst); - //~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as } diff --git a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.stderr b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.stderr index d5e53418b6fb8..021654cf35eed 100644 --- a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.stderr +++ b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.stderr @@ -1,5 +1,5 @@ error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:22:67 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:28:67 | LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Relaxed, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -8,7 +8,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Relaxed, Ordering: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:24:67 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:30:67 | LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -16,7 +16,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:26:67 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:32:67 | LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -24,7 +24,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:28:66 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:34:66 | LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -32,7 +32,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering:: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:30:66 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:36:66 | LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::SeqCst, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -40,7 +40,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::SeqCst, Ordering:: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:34:67 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:40:67 | LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -48,7 +48,7 @@ LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:36:67 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:42:67 | LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -56,7 +56,7 @@ LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:38:67 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:44:67 | LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -64,7 +64,7 @@ LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:40:66 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:46:66 | LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -72,66 +72,12 @@ LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering:: = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange_weak` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:42:66 + --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:48:66 | LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering | = help: consider using `Acquire` or `Relaxed` failure ordering instead -error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:46:48 - | -LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::Acquire); - | ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering - | | - | `Release` success ordering - | help: consider using `AcqRel` success ordering instead - -error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:48:48 - | -LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Release` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:52:48 - | -LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Relaxed` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:54:48 - | -LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Acquire); - | ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering - | | - | `Relaxed` success ordering - | help: consider using `Acquire` success ordering instead - -error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:58:48 - | -LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Acquire` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:60:48 - | -LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `AcqRel` success ordering - | help: consider using `SeqCst` success ordering instead - -error: aborting due to 16 previous errors +error: aborting due to 10 previous errors diff --git a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.rs b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.rs index da98d854262a5..488d268eee810 100644 --- a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.rs +++ b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.rs @@ -7,11 +7,17 @@ fn main() { // Allowed ordering combos let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Relaxed); - let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::Acquire); + let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Acquire); + let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::SeqCst); let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::Relaxed); + let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::Acquire); + let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::SeqCst); let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Relaxed); - let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::Acquire); + let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Acquire); + let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::SeqCst); let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::Relaxed); + let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::Acquire); + let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::SeqCst); let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::Relaxed); let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::Acquire); let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::SeqCst); @@ -39,22 +45,4 @@ fn main() { //~^ ERROR `compare_exchange`'s failure ordering may not be `Release` or `AcqRel` let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::Release); //~^ ERROR `compare_exchange`'s failure ordering may not be `Release` or `AcqRel` - - // Release success order forbids failure order of Acquire or SeqCst - let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Acquire); - //~^ ERROR `compare_exchange`'s success ordering must be at least as strong as - let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::SeqCst); - //~^ ERROR `compare_exchange`'s success ordering must be at least as strong as - - // Relaxed success order also forbids failure order of Acquire or SeqCst - let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::SeqCst); - //~^ ERROR `compare_exchange`'s success ordering must be at least as strong as - let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Acquire); - //~^ ERROR `compare_exchange`'s success ordering must be at least as strong as - - // Acquire/AcqRel forbids failure order of SeqCst - let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::SeqCst); - //~^ ERROR `compare_exchange`'s success ordering must be at least as strong as - let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::SeqCst); - //~^ ERROR `compare_exchange`'s success ordering must be at least as strong as } diff --git a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.stderr b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.stderr index 41121a20dee99..f6f8f88e88457 100644 --- a/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.stderr +++ b/src/test/ui/lint/lint-invalid-atomic-ordering-exchange.stderr @@ -1,5 +1,5 @@ error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:20:57 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:26:57 | LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -8,7 +8,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::AcqRel); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:22:57 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:28:57 | LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -16,7 +16,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::AcqRel); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:24:57 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:30:57 | LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -24,7 +24,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::AcqRel); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:26:56 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:32:56 | LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -32,7 +32,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::AcqRel); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:28:56 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:34:56 | LL | let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::AcqRel); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -40,7 +40,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::AcqRel); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:32:57 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:38:57 | LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -48,7 +48,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Release); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:34:57 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:40:57 | LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -56,7 +56,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::Release); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:36:57 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:42:57 | LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -64,7 +64,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Release); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:38:56 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:44:56 | LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -72,66 +72,12 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::Release); = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `compare_exchange`'s failure ordering may not be `Release` or `AcqRel`, since a failed `compare_exchange` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:40:56 + --> $DIR/lint-invalid-atomic-ordering-exchange.rs:46:56 | LL | let _ = x.compare_exchange(0, 0, Ordering::SeqCst, Ordering::Release); | ^^^^^^^^^^^^^^^^^ invalid failure ordering | = help: consider using `Acquire` or `Relaxed` failure ordering instead -error: `compare_exchange`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:44:38 - | -LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Acquire); - | ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering - | | - | `Release` success ordering - | help: consider using `AcqRel` success ordering instead - -error: `compare_exchange`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:46:38 - | -LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Release` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `compare_exchange`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:50:38 - | -LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Relaxed` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `compare_exchange`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:52:38 - | -LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Acquire); - | ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering - | | - | `Relaxed` success ordering - | help: consider using `Acquire` success ordering instead - -error: `compare_exchange`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:56:38 - | -LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Acquire` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `compare_exchange`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-exchange.rs:58:38 - | -LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::SeqCst); - | ^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `AcqRel` success ordering - | help: consider using `SeqCst` success ordering instead - -error: aborting due to 16 previous errors +error: aborting due to 10 previous errors diff --git a/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.rs b/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.rs index 73eda182aa879..734b63324af25 100644 --- a/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.rs +++ b/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.rs @@ -7,11 +7,17 @@ fn main() { // Allowed ordering combos let _ = x.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |old| Some(old + 1)); - let _ = x.fetch_update(Ordering::Acquire, Ordering::Acquire, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::Relaxed, Ordering::Acquire, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::Relaxed, Ordering::SeqCst, |old| Some(old + 1)); let _ = x.fetch_update(Ordering::Acquire, Ordering::Relaxed, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::Acquire, Ordering::Acquire, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::Acquire, Ordering::SeqCst, |old| Some(old + 1)); let _ = x.fetch_update(Ordering::Release, Ordering::Relaxed, |old| Some(old + 1)); - let _ = x.fetch_update(Ordering::AcqRel, Ordering::Acquire, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::Release, Ordering::Acquire, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::Release, Ordering::SeqCst, |old| Some(old + 1)); let _ = x.fetch_update(Ordering::AcqRel, Ordering::Relaxed, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::AcqRel, Ordering::Acquire, |old| Some(old + 1)); + let _ = x.fetch_update(Ordering::AcqRel, Ordering::SeqCst, |old| Some(old + 1)); let _ = x.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |old| Some(old + 1)); let _ = x.fetch_update(Ordering::SeqCst, Ordering::Acquire, |old| Some(old + 1)); let _ = x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |old| Some(old + 1)); @@ -40,21 +46,4 @@ fn main() { let _ = x.fetch_update(Ordering::SeqCst, Ordering::Release, |old| Some(old + 1)); //~^ ERROR `fetch_update`'s failure ordering may not be `Release` or `AcqRel` - // Release success order forbids failure order of Acquire or SeqCst - let _ = x.fetch_update(Ordering::Release, Ordering::Acquire, |old| Some(old + 1)); - //~^ ERROR `fetch_update`'s success ordering must be at least as strong as - let _ = x.fetch_update(Ordering::Release, Ordering::SeqCst, |old| Some(old + 1)); - //~^ ERROR `fetch_update`'s success ordering must be at least as strong as - - // Relaxed success order also forbids failure order of Acquire or SeqCst - let _ = x.fetch_update(Ordering::Relaxed, Ordering::SeqCst, |old| Some(old + 1)); - //~^ ERROR `fetch_update`'s success ordering must be at least as strong as - let _ = x.fetch_update(Ordering::Relaxed, Ordering::Acquire, |old| Some(old + 1)); - //~^ ERROR `fetch_update`'s success ordering must be at least as strong as - - // Acquire/AcqRel forbids failure order of SeqCst - let _ = x.fetch_update(Ordering::Acquire, Ordering::SeqCst, |old| Some(old + 1)); - //~^ ERROR `fetch_update`'s success ordering must be at least as strong as - let _ = x.fetch_update(Ordering::AcqRel, Ordering::SeqCst, |old| Some(old + 1)); - //~^ ERROR `fetch_update`'s success ordering must be at least as strong as } diff --git a/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.stderr b/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.stderr index 7bea56d57fbab..267b1c706ef17 100644 --- a/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.stderr +++ b/src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.stderr @@ -1,5 +1,5 @@ error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:20:47 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:26:47 | LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -8,7 +8,7 @@ LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::AcqRel, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:22:47 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:28:47 | LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -16,7 +16,7 @@ LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::AcqRel, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:24:47 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:30:47 | LL | let _ = x.fetch_update(Ordering::Release, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -24,7 +24,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::AcqRel, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:26:46 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:32:46 | LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -32,7 +32,7 @@ LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::AcqRel, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:28:46 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:34:46 | LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::AcqRel, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^ invalid failure ordering @@ -40,7 +40,7 @@ LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::AcqRel, |old| Some(o = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:32:47 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:38:47 | LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -48,7 +48,7 @@ LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::Release, |old| Some = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:34:47 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:40:47 | LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -56,7 +56,7 @@ LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::Release, |old| Some = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:36:47 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:42:47 | LL | let _ = x.fetch_update(Ordering::Release, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -64,7 +64,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::Release, |old| Some = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:38:46 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:44:46 | LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering @@ -72,66 +72,12 @@ LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::Release, |old| Some( = help: consider using `Acquire` or `Relaxed` failure ordering instead error: `fetch_update`'s failure ordering may not be `Release` or `AcqRel`, since a failed `fetch_update` does not result in a write - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:40:46 + --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:46:46 | LL | let _ = x.fetch_update(Ordering::SeqCst, Ordering::Release, |old| Some(old + 1)); | ^^^^^^^^^^^^^^^^^ invalid failure ordering | = help: consider using `Acquire` or `Relaxed` failure ordering instead -error: `fetch_update`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:44:28 - | -LL | let _ = x.fetch_update(Ordering::Release, Ordering::Acquire, |old| Some(old + 1)); - | ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering - | | - | `Release` success ordering - | help: consider using `AcqRel` success ordering instead - -error: `fetch_update`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:46:28 - | -LL | let _ = x.fetch_update(Ordering::Release, Ordering::SeqCst, |old| Some(old + 1)); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Release` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `fetch_update`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:50:28 - | -LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::SeqCst, |old| Some(old + 1)); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Relaxed` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `fetch_update`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:52:28 - | -LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::Acquire, |old| Some(old + 1)); - | ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering - | | - | `Relaxed` success ordering - | help: consider using `Acquire` success ordering instead - -error: `fetch_update`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:56:28 - | -LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::SeqCst, |old| Some(old + 1)); - | ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `Acquire` success ordering - | help: consider using `SeqCst` success ordering instead - -error: `fetch_update`'s success ordering must be at least as strong as its failure ordering - --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:58:28 - | -LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::SeqCst, |old| Some(old + 1)); - | ^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering - | | - | `AcqRel` success ordering - | help: consider using `SeqCst` success ordering instead - -error: aborting due to 16 previous errors +error: aborting due to 10 previous errors