Skip to content

Commit 1c1f221

Browse files
committed
Tweak memory ordering diagnostic.
1 parent 1b83dcf commit 1c1f221

4 files changed

+24
-37
lines changed

compiler/rustc_lint/src/types.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,12 @@ impl InvalidAtomicOrdering {
15821582
))
15831583
.span_label(fail_order_arg.span, format!("{fail_ordering} failure ordering"))
15841584
.span_label(success_order_arg.span, format!("{success_ordering} success ordering"))
1585-
.help(format!("consider using {success_suggestion} success ordering instead"))
1585+
.span_suggestion_short(
1586+
success_order_arg.span,
1587+
format!("consider using {success_suggestion} success ordering instead"),
1588+
success_suggestion.to_string(),
1589+
Applicability::MaybeIncorrect,
1590+
)
15861591
.emit();
15871592
});
15881593
}

src/test/ui/lint/lint-invalid-atomic-ordering-exchange-weak.stderr

+6-12
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering:
8686
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
8787
| |
8888
| Release success ordering
89-
|
90-
= help: consider using AcqRel success ordering instead
89+
| help: consider using AcqRel success ordering instead
9190

9291
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
9392
--> $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:
9695
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
9796
| |
9897
| Release success ordering
99-
|
100-
= help: consider using SeqCst success ordering instead
98+
| help: consider using SeqCst success ordering instead
10199

102100
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
103101
--> $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:
106104
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
107105
| |
108106
| Relaxed success ordering
109-
|
110-
= help: consider using SeqCst success ordering instead
107+
| help: consider using SeqCst success ordering instead
111108

112109
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
113110
--> $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:
116113
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
117114
| |
118115
| Relaxed success ordering
119-
|
120-
= help: consider using Acquire success ordering instead
116+
| help: consider using Acquire success ordering instead
121117

122118
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
123119
--> $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:
126122
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
127123
| |
128124
| Acquire success ordering
129-
|
130-
= help: consider using SeqCst success ordering instead
125+
| help: consider using SeqCst success ordering instead
131126

132127
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
133128
--> $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::
136131
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
137132
| |
138133
| AcqRel success ordering
139-
|
140-
= help: consider using SeqCst success ordering instead
134+
| help: consider using SeqCst success ordering instead
141135

142136
error: aborting due to 16 previous errors
143137

src/test/ui/lint/lint-invalid-atomic-ordering-exchange.stderr

+6-12
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::Acquire);
8686
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
8787
| |
8888
| Release success ordering
89-
|
90-
= help: consider using AcqRel success ordering instead
89+
| help: consider using AcqRel success ordering instead
9190

9291
error: compare_exchange's success ordering must be at least as strong as its failure ordering
9392
--> $DIR/lint-invalid-atomic-ordering-exchange.rs:46:38
@@ -96,8 +95,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Release, Ordering::SeqCst);
9695
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
9796
| |
9897
| Release success ordering
99-
|
100-
= help: consider using SeqCst success ordering instead
98+
| help: consider using SeqCst success ordering instead
10199

102100
error: compare_exchange's success ordering must be at least as strong as its failure ordering
103101
--> $DIR/lint-invalid-atomic-ordering-exchange.rs:50:38
@@ -106,8 +104,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::SeqCst);
106104
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
107105
| |
108106
| Relaxed success ordering
109-
|
110-
= help: consider using SeqCst success ordering instead
107+
| help: consider using SeqCst success ordering instead
111108

112109
error: compare_exchange's success ordering must be at least as strong as its failure ordering
113110
--> $DIR/lint-invalid-atomic-ordering-exchange.rs:52:38
@@ -116,8 +113,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Relaxed, Ordering::Acquire);
116113
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
117114
| |
118115
| Relaxed success ordering
119-
|
120-
= help: consider using Acquire success ordering instead
116+
| help: consider using Acquire success ordering instead
121117

122118
error: compare_exchange's success ordering must be at least as strong as its failure ordering
123119
--> $DIR/lint-invalid-atomic-ordering-exchange.rs:56:38
@@ -126,8 +122,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::Acquire, Ordering::SeqCst);
126122
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
127123
| |
128124
| Acquire success ordering
129-
|
130-
= help: consider using SeqCst success ordering instead
125+
| help: consider using SeqCst success ordering instead
131126

132127
error: compare_exchange's success ordering must be at least as strong as its failure ordering
133128
--> $DIR/lint-invalid-atomic-ordering-exchange.rs:58:38
@@ -136,8 +131,7 @@ LL | let _ = x.compare_exchange(0, 0, Ordering::AcqRel, Ordering::SeqCst);
136131
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
137132
| |
138133
| AcqRel success ordering
139-
|
140-
= help: consider using SeqCst success ordering instead
134+
| help: consider using SeqCst success ordering instead
141135

142136
error: aborting due to 16 previous errors
143137

src/test/ui/lint/lint-invalid-atomic-ordering-fetch-update.stderr

+6-12
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ LL | let _ = x.fetch_update(Ordering::Release, Ordering::Acquire, |old| Some
8686
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
8787
| |
8888
| Release success ordering
89-
|
90-
= help: consider using AcqRel success ordering instead
89+
| help: consider using AcqRel success ordering instead
9190

9291
error: fetch_update's success ordering must be at least as strong as its failure ordering
9392
--> $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(
9695
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
9796
| |
9897
| Release success ordering
99-
|
100-
= help: consider using SeqCst success ordering instead
98+
| help: consider using SeqCst success ordering instead
10199

102100
error: fetch_update's success ordering must be at least as strong as its failure ordering
103101
--> $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(
106104
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
107105
| |
108106
| Relaxed success ordering
109-
|
110-
= help: consider using SeqCst success ordering instead
107+
| help: consider using SeqCst success ordering instead
111108

112109
error: fetch_update's success ordering must be at least as strong as its failure ordering
113110
--> $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
116113
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
117114
| |
118115
| Relaxed success ordering
119-
|
120-
= help: consider using Acquire success ordering instead
116+
| help: consider using Acquire success ordering instead
121117

122118
error: fetch_update's success ordering must be at least as strong as its failure ordering
123119
--> $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(
126122
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
127123
| |
128124
| Acquire success ordering
129-
|
130-
= help: consider using SeqCst success ordering instead
125+
| help: consider using SeqCst success ordering instead
131126

132127
error: fetch_update's success ordering must be at least as strong as its failure ordering
133128
--> $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
136131
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
137132
| |
138133
| AcqRel success ordering
139-
|
140-
= help: consider using SeqCst success ordering instead
134+
| help: consider using SeqCst success ordering instead
141135

142136
error: aborting due to 16 previous errors
143137

0 commit comments

Comments
 (0)