1
Fork 0

Tweak memory ordering diagnostic.

This commit is contained in:
Mara Bos 2022-05-25 12:18:48 +02:00
parent 1b83dcffce
commit 1c1f221845
4 changed files with 24 additions and 37 deletions

View file

@ -1582,7 +1582,12 @@ impl InvalidAtomicOrdering {
)) ))
.span_label(fail_order_arg.span, format!("{fail_ordering} 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(success_order_arg.span, format!("{success_ordering} success ordering"))
.help(format!("consider using {success_suggestion} success ordering instead")) .span_suggestion_short(
success_order_arg.span,
format!("consider using {success_suggestion} success ordering instead"),
success_suggestion.to_string(),
Applicability::MaybeIncorrect,
)
.emit(); .emit();
}); });
} }

View file

@ -86,8 +86,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering:
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering | ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
| | | |
| Release success ordering | Release success ordering
| | help: consider using AcqRel success ordering instead
= 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 --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:48:48
@ -96,8 +95,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering:
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Release success ordering | Release success ordering
| | help: consider using SeqCst success ordering instead
= 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 --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:52:48
@ -106,8 +104,7 @@ LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering:
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Relaxed success ordering | Relaxed success ordering
| | help: consider using SeqCst success ordering instead
= 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 --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:54:48
@ -116,8 +113,7 @@ LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering:
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering | ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
| | | |
| Relaxed success ordering | Relaxed success ordering
| | help: consider using Acquire success ordering instead
= 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 --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:58:48
@ -126,8 +122,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering:
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Acquire success ordering | Acquire success ordering
| | help: consider using SeqCst success ordering instead
= 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 --> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:60:48
@ -136,8 +131,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| AcqRel success ordering | AcqRel success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: aborting due to 16 previous errors error: aborting due to 16 previous errors

View file

@ -86,8 +86,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Acquire);
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering | ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
| | | |
| Release success ordering | Release success ordering
| | help: consider using AcqRel success ordering instead
= help: consider using AcqRel success ordering instead
error: compare_exchange's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-exchange.rs:46:38
@ -96,8 +95,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Release success ordering | Release success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: compare_exchange's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-exchange.rs:50:38
@ -106,8 +104,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Relaxed success ordering | Relaxed success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: compare_exchange's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-exchange.rs:52:38
@ -116,8 +113,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Acquire);
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering | ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
| | | |
| Relaxed success ordering | Relaxed success ordering
| | help: consider using Acquire success ordering instead
= help: consider using Acquire success ordering instead
error: compare_exchange's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-exchange.rs:56:38
@ -126,8 +122,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Acquire success ordering | Acquire success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: compare_exchange's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-exchange.rs:58:38
@ -136,8 +131,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| AcqRel success ordering | AcqRel success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: aborting due to 16 previous errors error: aborting due to 16 previous errors

View file

@ -86,8 +86,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::Acquire, |old| Some
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering | ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
| | | |
| Release success ordering | Release success ordering
| | help: consider using AcqRel success ordering instead
= help: consider using AcqRel success ordering instead
error: fetch_update's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:46:28
@ -96,8 +95,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::SeqCst, |old| Some(
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Release success ordering | Release success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: fetch_update's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:50:28
@ -106,8 +104,7 @@ LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::SeqCst, |old| Some(
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Relaxed success ordering | Relaxed success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: fetch_update's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:52:28
@ -116,8 +113,7 @@ LL | let _ = x.fetch_update(Ordering::Relaxed, Ordering::Acquire, |old| Some
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering | ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
| | | |
| Relaxed success ordering | Relaxed success ordering
| | help: consider using Acquire success ordering instead
= help: consider using Acquire success ordering instead
error: fetch_update's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:56:28
@ -126,8 +122,7 @@ LL | let _ = x.fetch_update(Ordering::Acquire, Ordering::SeqCst, |old| Some(
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| Acquire success ordering | Acquire success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: fetch_update's success ordering must be at least as strong as its failure ordering 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 --> $DIR/lint-invalid-atomic-ordering-fetch-update.rs:58:28
@ -136,8 +131,7 @@ LL | let _ = x.fetch_update(Ordering::AcqRel, Ordering::SeqCst, |old| Some(o
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering | ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
| | | |
| AcqRel success ordering | AcqRel success ordering
| | help: consider using SeqCst success ordering instead
= help: consider using SeqCst success ordering instead
error: aborting due to 16 previous errors error: aborting due to 16 previous errors