Skip to content

Commit

Permalink
Slightly tweak invalid atomic ordering lint messages.
Browse files Browse the repository at this point in the history
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
  • Loading branch information
m-ou-se and estebank committed Jun 22, 2022
1 parent 1c1f221 commit f107923
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 188 deletions.
16 changes: 8 additions & 8 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,11 +1554,11 @@ impl InvalidAtomicOrdering {
if matches!(fail_ordering, sym::Release | sym::AcqRel) {
cx.struct_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg.span, |diag| {
diag.build(&format!(
"{method}'s failure ordering may not be `Release` or `AcqRel`, \
since a failed {method} does not result in a write",
"`{method}`'s failure ordering may not be `Release` or `AcqRel`, \
since a failed `{method}` does not result in a write",
))
.span_label(fail_order_arg.span, "invalid failure ordering")
.help("consider using Acquire or Relaxed failure ordering instead")
.help("consider using `Acquire` or `Relaxed` failure ordering instead")
.emit();
});
}
Expand All @@ -1578,14 +1578,14 @@ impl InvalidAtomicOrdering {
};
cx.struct_span_lint(INVALID_ATOMIC_ORDERING, success_order_arg.span, |diag| {
diag.build(&format!(
"{method}'s success ordering must be at least as strong as its failure ordering"
"`{method}`'s success ordering must be at least as strong as its failure ordering"
))
.span_label(fail_order_arg.span, format!("{fail_ordering} failure ordering"))
.span_label(success_order_arg.span, format!("{success_ordering} success ordering"))
.span_label(fail_order_arg.span, format!("`{fail_ordering}` failure ordering"))
.span_label(success_order_arg.span, format!("`{success_ordering}` success ordering"))
.span_suggestion_short(
success_order_arg.span,
format!("consider using {success_suggestion} success ordering instead"),
success_suggestion.to_string(),
format!("consider using `{success_suggestion}` success ordering instead"),
format!("std::sync::atomic::Ordering::{success_suggestion}"),
Applicability::MaybeIncorrect,
)
.emit();
Expand Down
32 changes: 16 additions & 16 deletions src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,43 @@ fn main() {

// AcqRel is always forbidden as a failure ordering
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Relaxed, Ordering::AcqRel);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::AcqRel);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::AcqRel);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::AcqRel);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::SeqCst, Ordering::AcqRel);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`

// Release is always forbidden as a failure ordering
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Release);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Release);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering::Release);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Release);
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
//~^ 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`
//~^ 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
//~^ 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
//~^ 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
//~^ 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
//~^ 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
//~^ 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
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
}
88 changes: 44 additions & 44 deletions src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.stderr
Original file line number Diff line number Diff line change
@@ -1,137 +1,137 @@
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
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
|
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Relaxed, Ordering::AcqRel);
| ^^^^^^^^^^^^^^^^ invalid failure ordering
|
= note: `#[deny(invalid_atomic_ordering)]` on by default
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::AcqRel);
| ^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::AcqRel);
| ^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::AcqRel);
| ^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::SeqCst, Ordering::AcqRel);
| ^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Release);
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Release);
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering::Release);
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Release);
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
|
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Release);
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
|
= help: consider using Acquire or Relaxed failure ordering instead
= 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
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
| ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering
| |
| Release success ordering
| help: consider using AcqRel success ordering instead
| `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
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
| ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
| |
| Release success ordering
| help: consider using SeqCst success ordering instead
| `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
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
| ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
| |
| Relaxed success ordering
| help: consider using SeqCst success ordering instead
| `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
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
| ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering
| |
| Relaxed success ordering
| help: consider using Acquire success ordering instead
| `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
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
| ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
| |
| Acquire success ordering
| help: consider using SeqCst success ordering instead
| `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
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
| ^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
| |
| AcqRel success ordering
| help: consider using SeqCst success ordering instead
| `AcqRel` success ordering
| help: consider using `SeqCst` success ordering instead

error: aborting due to 16 previous errors

Loading

0 comments on commit f107923

Please sign in to comment.