Skip to content

Commit f107923

Browse files
m-ou-seestebank
andcommitted
Slightly tweak invalid atomic ordering lint messages.
Co-authored-by: Esteban Kuber <[email protected]>
1 parent 1c1f221 commit f107923

7 files changed

+188
-188
lines changed

compiler/rustc_lint/src/types.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1554,11 +1554,11 @@ impl InvalidAtomicOrdering {
15541554
if matches!(fail_ordering, sym::Release | sym::AcqRel) {
15551555
cx.struct_span_lint(INVALID_ATOMIC_ORDERING, fail_order_arg.span, |diag| {
15561556
diag.build(&format!(
1557-
"{method}'s failure ordering may not be `Release` or `AcqRel`, \
1558-
since a failed {method} does not result in a write",
1557+
"`{method}`'s failure ordering may not be `Release` or `AcqRel`, \
1558+
since a failed `{method}` does not result in a write",
15591559
))
15601560
.span_label(fail_order_arg.span, "invalid failure ordering")
1561-
.help("consider using Acquire or Relaxed failure ordering instead")
1561+
.help("consider using `Acquire` or `Relaxed` failure ordering instead")
15621562
.emit();
15631563
});
15641564
}
@@ -1578,14 +1578,14 @@ impl InvalidAtomicOrdering {
15781578
};
15791579
cx.struct_span_lint(INVALID_ATOMIC_ORDERING, success_order_arg.span, |diag| {
15801580
diag.build(&format!(
1581-
"{method}'s success ordering must be at least as strong as its failure ordering"
1581+
"`{method}`'s success ordering must be at least as strong as its failure ordering"
15821582
))
1583-
.span_label(fail_order_arg.span, format!("{fail_ordering} failure ordering"))
1584-
.span_label(success_order_arg.span, format!("{success_ordering} success ordering"))
1583+
.span_label(fail_order_arg.span, format!("`{fail_ordering}` failure ordering"))
1584+
.span_label(success_order_arg.span, format!("`{success_ordering}` success ordering"))
15851585
.span_suggestion_short(
15861586
success_order_arg.span,
1587-
format!("consider using {success_suggestion} success ordering instead"),
1588-
success_suggestion.to_string(),
1587+
format!("consider using `{success_suggestion}` success ordering instead"),
1588+
format!("std::sync::atomic::Ordering::{success_suggestion}"),
15891589
Applicability::MaybeIncorrect,
15901590
)
15911591
.emit();

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

+16-16
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,43 @@ fn main() {
2020

2121
// AcqRel is always forbidden as a failure ordering
2222
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Relaxed, Ordering::AcqRel);
23-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
23+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
2424
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::AcqRel);
25-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
25+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
2626
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::AcqRel);
27-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
27+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
2828
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::AcqRel);
29-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
29+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
3030
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::SeqCst, Ordering::AcqRel);
31-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
31+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
3232

3333
// Release is always forbidden as a failure ordering
3434
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Release);
35-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
35+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
3636
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Release);
37-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
37+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
3838
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering::Release);
39-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
39+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
4040
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Release);
41-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
41+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
4242
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Release);
43-
//~^ ERROR compare_exchange_weak's failure ordering may not be `Release` or `AcqRel`
43+
//~^ ERROR `compare_exchange_weak`'s failure ordering may not be `Release` or `AcqRel`
4444

4545
// Release success order forbids failure order of Acquire or SeqCst
4646
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::Acquire);
47-
//~^ ERROR compare_exchange_weak's success ordering must be at least as strong as
47+
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
4848
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::SeqCst);
49-
//~^ ERROR compare_exchange_weak's success ordering must be at least as strong as
49+
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
5050

5151
// Relaxed success order also forbids failure order of Acquire or SeqCst
5252
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::SeqCst);
53-
//~^ ERROR compare_exchange_weak's success ordering must be at least as strong as
53+
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
5454
let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Acquire);
55-
//~^ ERROR compare_exchange_weak's success ordering must be at least as strong as
55+
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
5656

5757
// Acquire/AcqRel forbids failure order of SeqCst
5858
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::SeqCst);
59-
//~^ ERROR compare_exchange_weak's success ordering must be at least as strong as
59+
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
6060
let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::SeqCst);
61-
//~^ ERROR compare_exchange_weak's success ordering must be at least as strong as
61+
//~^ ERROR `compare_exchange_weak`'s success ordering must be at least as strong as
6262
}
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,137 @@
1-
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
1+
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
22
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:22:67
33
|
44
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Relaxed, Ordering::AcqRel);
55
| ^^^^^^^^^^^^^^^^ invalid failure ordering
66
|
77
= note: `#[deny(invalid_atomic_ordering)]` on by default
8-
= help: consider using Acquire or Relaxed failure ordering instead
8+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
99

10-
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
10+
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
1111
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:24:67
1212
|
1313
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::AcqRel);
1414
| ^^^^^^^^^^^^^^^^ invalid failure ordering
1515
|
16-
= help: consider using Acquire or Relaxed failure ordering instead
16+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
1717

18-
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
18+
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
1919
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:26:67
2020
|
2121
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::AcqRel);
2222
| ^^^^^^^^^^^^^^^^ invalid failure ordering
2323
|
24-
= help: consider using Acquire or Relaxed failure ordering instead
24+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
2525

26-
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
26+
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
2727
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:28:66
2828
|
2929
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::AcqRel);
3030
| ^^^^^^^^^^^^^^^^ invalid failure ordering
3131
|
32-
= help: consider using Acquire or Relaxed failure ordering instead
32+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
3333

34-
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
34+
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
3535
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:30:66
3636
|
3737
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::SeqCst, Ordering::AcqRel);
3838
| ^^^^^^^^^^^^^^^^ invalid failure ordering
3939
|
40-
= help: consider using Acquire or Relaxed failure ordering instead
40+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
4141

42-
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
42+
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
4343
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:34:67
4444
|
4545
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Release);
4646
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
4747
|
48-
= help: consider using Acquire or Relaxed failure ordering instead
48+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
4949

50-
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
50+
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
5151
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:36:67
5252
|
5353
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Acquire, Ordering::Release);
5454
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
5555
|
56-
= help: consider using Acquire or Relaxed failure ordering instead
56+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
5757

58-
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
58+
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
5959
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:38:67
6060
|
6161
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Release, Ordering::Release);
6262
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
6363
|
64-
= help: consider using Acquire or Relaxed failure ordering instead
64+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
6565

66-
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
66+
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
6767
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:40:66
6868
|
6969
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::AcqRel, Ordering::Release);
7070
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
7171
|
72-
= help: consider using Acquire or Relaxed failure ordering instead
72+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
7373

74-
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
74+
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
7575
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:42:66
7676
|
7777
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::SeqCst, Ordering::Release);
7878
| ^^^^^^^^^^^^^^^^^ invalid failure ordering
7979
|
80-
= help: consider using Acquire or Relaxed failure ordering instead
80+
= help: consider using `Acquire` or `Relaxed` failure ordering instead
8181

82-
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
82+
error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering
8383
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:46:48
8484
|
8585
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::Acquire);
86-
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
86+
| ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering
8787
| |
88-
| Release success ordering
89-
| help: consider using AcqRel success ordering instead
88+
| `Release` success ordering
89+
| help: consider using `AcqRel` success ordering instead
9090

91-
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
91+
error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering
9292
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:48:48
9393
|
9494
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Release, Ordering::SeqCst);
95-
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
95+
| ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
9696
| |
97-
| Release success ordering
98-
| help: consider using SeqCst success ordering instead
97+
| `Release` success ordering
98+
| help: consider using `SeqCst` success ordering instead
9999

100-
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
100+
error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering
101101
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:52:48
102102
|
103103
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::SeqCst);
104-
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
104+
| ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
105105
| |
106-
| Relaxed success ordering
107-
| help: consider using SeqCst success ordering instead
106+
| `Relaxed` success ordering
107+
| help: consider using `SeqCst` success ordering instead
108108

109-
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
109+
error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering
110110
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:54:48
111111
|
112112
LL | let _ = x.compare_exchange_weak(ptr, ptr2, Ordering::Relaxed, Ordering::Acquire);
113-
| ^^^^^^^^^^^^^^^^^ ----------------- Acquire failure ordering
113+
| ^^^^^^^^^^^^^^^^^ ----------------- `Acquire` failure ordering
114114
| |
115-
| Relaxed success ordering
116-
| help: consider using Acquire success ordering instead
115+
| `Relaxed` success ordering
116+
| help: consider using `Acquire` success ordering instead
117117

118-
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
118+
error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering
119119
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:58:48
120120
|
121121
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::Acquire, Ordering::SeqCst);
122-
| ^^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
122+
| ^^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
123123
| |
124-
| Acquire success ordering
125-
| help: consider using SeqCst success ordering instead
124+
| `Acquire` success ordering
125+
| help: consider using `SeqCst` success ordering instead
126126

127-
error: compare_exchange_weak's success ordering must be at least as strong as its failure ordering
127+
error: `compare_exchange_weak`'s success ordering must be at least as strong as its failure ordering
128128
--> $DIR/lint-invalid-atomic-ordering-exchange-weak.rs:60:48
129129
|
130130
LL | let _ = x.compare_exchange_weak(ptr2, ptr, Ordering::AcqRel, Ordering::SeqCst);
131-
| ^^^^^^^^^^^^^^^^ ---------------- SeqCst failure ordering
131+
| ^^^^^^^^^^^^^^^^ ---------------- `SeqCst` failure ordering
132132
| |
133-
| AcqRel success ordering
134-
| help: consider using SeqCst success ordering instead
133+
| `AcqRel` success ordering
134+
| help: consider using `SeqCst` success ordering instead
135135

136136
error: aborting due to 16 previous errors
137137

0 commit comments

Comments
 (0)