Skip to content

Commit dc8c7b1

Browse files
committed
Atomics constants are now handled by the deprecation lint
1 parent 36245fe commit dc8c7b1

File tree

4 files changed

+27
-132
lines changed

4 files changed

+27
-132
lines changed

clippy_lints/src/replace_consts.rs

-15
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ReplaceConsts {
6969
const REPLACEMENTS: &[(&[&str], &str)] = &[
7070
// Once
7171
(&["core", "sync", "ONCE_INIT"], "Once::new()"),
72-
// Atomic
73-
(
74-
&["core", "sync", "atomic", "ATOMIC_BOOL_INIT"],
75-
"AtomicBool::new(false)",
76-
),
77-
(&["core", "sync", "atomic", "ATOMIC_ISIZE_INIT"], "AtomicIsize::new(0)"),
78-
(&["core", "sync", "atomic", "ATOMIC_I8_INIT"], "AtomicI8::new(0)"),
79-
(&["core", "sync", "atomic", "ATOMIC_I16_INIT"], "AtomicI16::new(0)"),
80-
(&["core", "sync", "atomic", "ATOMIC_I32_INIT"], "AtomicI32::new(0)"),
81-
(&["core", "sync", "atomic", "ATOMIC_I64_INIT"], "AtomicI64::new(0)"),
82-
(&["core", "sync", "atomic", "ATOMIC_USIZE_INIT"], "AtomicUsize::new(0)"),
83-
(&["core", "sync", "atomic", "ATOMIC_U8_INIT"], "AtomicU8::new(0)"),
84-
(&["core", "sync", "atomic", "ATOMIC_U16_INIT"], "AtomicU16::new(0)"),
85-
(&["core", "sync", "atomic", "ATOMIC_U32_INIT"], "AtomicU32::new(0)"),
86-
(&["core", "sync", "atomic", "ATOMIC_U64_INIT"], "AtomicU64::new(0)"),
8772
// Min
8873
(&["core", "isize", "MIN"], "isize::min_value()"),
8974
(&["core", "i8", "MIN"], "i8::min_value()"),

tests/ui/replace_consts.fixed

-12
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ use std::sync::{Once, ONCE_INIT};
1010
fn bad() {
1111
// Once
1212
{ let foo = ONCE_INIT; };
13-
// Atomic
14-
{ let foo = AtomicBool::new(false); };
15-
{ let foo = AtomicIsize::new(0); };
16-
{ let foo = AtomicI8::new(0); };
17-
{ let foo = AtomicI16::new(0); };
18-
{ let foo = AtomicI32::new(0); };
19-
{ let foo = AtomicI64::new(0); };
20-
{ let foo = AtomicUsize::new(0); };
21-
{ let foo = AtomicU8::new(0); };
22-
{ let foo = AtomicU16::new(0); };
23-
{ let foo = AtomicU32::new(0); };
24-
{ let foo = AtomicU64::new(0); };
2513
// Min
2614
{ let foo = isize::min_value(); };
2715
{ let foo = i8::min_value(); };

tests/ui/replace_consts.rs

-12
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ use std::sync::{Once, ONCE_INIT};
1010
fn bad() {
1111
// Once
1212
{ let foo = ONCE_INIT; };
13-
// Atomic
14-
{ let foo = ATOMIC_BOOL_INIT; };
15-
{ let foo = ATOMIC_ISIZE_INIT; };
16-
{ let foo = ATOMIC_I8_INIT; };
17-
{ let foo = ATOMIC_I16_INIT; };
18-
{ let foo = ATOMIC_I32_INIT; };
19-
{ let foo = ATOMIC_I64_INIT; };
20-
{ let foo = ATOMIC_USIZE_INIT; };
21-
{ let foo = ATOMIC_U8_INIT; };
22-
{ let foo = ATOMIC_U16_INIT; };
23-
{ let foo = ATOMIC_U32_INIT; };
24-
{ let foo = ATOMIC_U64_INIT; };
2513
// Min
2614
{ let foo = std::isize::MIN; };
2715
{ let foo = std::i8::MIN; };

tests/ui/replace_consts.stderr

+27-93
Original file line numberDiff line numberDiff line change
@@ -1,218 +1,152 @@
1-
error: using `ATOMIC_BOOL_INIT`
1+
error: using `MIN`
22
--> $DIR/replace_consts.rs:14:17
33
|
4-
LL | { let foo = ATOMIC_BOOL_INIT; };
5-
| ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)`
4+
LL | { let foo = std::isize::MIN; };
5+
| ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()`
66
|
77
note: lint level defined here
88
--> $DIR/replace_consts.rs:4:9
99
|
1010
LL | #![deny(clippy::replace_consts)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: using `ATOMIC_ISIZE_INIT`
14-
--> $DIR/replace_consts.rs:15:17
15-
|
16-
LL | { let foo = ATOMIC_ISIZE_INIT; };
17-
| ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)`
18-
19-
error: using `ATOMIC_I8_INIT`
20-
--> $DIR/replace_consts.rs:16:17
21-
|
22-
LL | { let foo = ATOMIC_I8_INIT; };
23-
| ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)`
24-
25-
error: using `ATOMIC_I16_INIT`
26-
--> $DIR/replace_consts.rs:17:17
27-
|
28-
LL | { let foo = ATOMIC_I16_INIT; };
29-
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)`
30-
31-
error: using `ATOMIC_I32_INIT`
32-
--> $DIR/replace_consts.rs:18:17
33-
|
34-
LL | { let foo = ATOMIC_I32_INIT; };
35-
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)`
36-
37-
error: using `ATOMIC_I64_INIT`
38-
--> $DIR/replace_consts.rs:19:17
39-
|
40-
LL | { let foo = ATOMIC_I64_INIT; };
41-
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)`
42-
43-
error: using `ATOMIC_USIZE_INIT`
44-
--> $DIR/replace_consts.rs:20:17
45-
|
46-
LL | { let foo = ATOMIC_USIZE_INIT; };
47-
| ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)`
48-
49-
error: using `ATOMIC_U8_INIT`
50-
--> $DIR/replace_consts.rs:21:17
51-
|
52-
LL | { let foo = ATOMIC_U8_INIT; };
53-
| ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)`
54-
55-
error: using `ATOMIC_U16_INIT`
56-
--> $DIR/replace_consts.rs:22:17
57-
|
58-
LL | { let foo = ATOMIC_U16_INIT; };
59-
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)`
60-
61-
error: using `ATOMIC_U32_INIT`
62-
--> $DIR/replace_consts.rs:23:17
63-
|
64-
LL | { let foo = ATOMIC_U32_INIT; };
65-
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)`
66-
67-
error: using `ATOMIC_U64_INIT`
68-
--> $DIR/replace_consts.rs:24:17
69-
|
70-
LL | { let foo = ATOMIC_U64_INIT; };
71-
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)`
72-
73-
error: using `MIN`
74-
--> $DIR/replace_consts.rs:26:17
75-
|
76-
LL | { let foo = std::isize::MIN; };
77-
| ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()`
78-
7913
error: using `MIN`
80-
--> $DIR/replace_consts.rs:27:17
14+
--> $DIR/replace_consts.rs:15:17
8115
|
8216
LL | { let foo = std::i8::MIN; };
8317
| ^^^^^^^^^^^^ help: try this: `i8::min_value()`
8418

8519
error: using `MIN`
86-
--> $DIR/replace_consts.rs:28:17
20+
--> $DIR/replace_consts.rs:16:17
8721
|
8822
LL | { let foo = std::i16::MIN; };
8923
| ^^^^^^^^^^^^^ help: try this: `i16::min_value()`
9024

9125
error: using `MIN`
92-
--> $DIR/replace_consts.rs:29:17
26+
--> $DIR/replace_consts.rs:17:17
9327
|
9428
LL | { let foo = std::i32::MIN; };
9529
| ^^^^^^^^^^^^^ help: try this: `i32::min_value()`
9630

9731
error: using `MIN`
98-
--> $DIR/replace_consts.rs:30:17
32+
--> $DIR/replace_consts.rs:18:17
9933
|
10034
LL | { let foo = std::i64::MIN; };
10135
| ^^^^^^^^^^^^^ help: try this: `i64::min_value()`
10236

10337
error: using `MIN`
104-
--> $DIR/replace_consts.rs:31:17
38+
--> $DIR/replace_consts.rs:19:17
10539
|
10640
LL | { let foo = std::i128::MIN; };
10741
| ^^^^^^^^^^^^^^ help: try this: `i128::min_value()`
10842

10943
error: using `MIN`
110-
--> $DIR/replace_consts.rs:32:17
44+
--> $DIR/replace_consts.rs:20:17
11145
|
11246
LL | { let foo = std::usize::MIN; };
11347
| ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()`
11448

11549
error: using `MIN`
116-
--> $DIR/replace_consts.rs:33:17
50+
--> $DIR/replace_consts.rs:21:17
11751
|
11852
LL | { let foo = std::u8::MIN; };
11953
| ^^^^^^^^^^^^ help: try this: `u8::min_value()`
12054

12155
error: using `MIN`
122-
--> $DIR/replace_consts.rs:34:17
56+
--> $DIR/replace_consts.rs:22:17
12357
|
12458
LL | { let foo = std::u16::MIN; };
12559
| ^^^^^^^^^^^^^ help: try this: `u16::min_value()`
12660

12761
error: using `MIN`
128-
--> $DIR/replace_consts.rs:35:17
62+
--> $DIR/replace_consts.rs:23:17
12963
|
13064
LL | { let foo = std::u32::MIN; };
13165
| ^^^^^^^^^^^^^ help: try this: `u32::min_value()`
13266

13367
error: using `MIN`
134-
--> $DIR/replace_consts.rs:36:17
68+
--> $DIR/replace_consts.rs:24:17
13569
|
13670
LL | { let foo = std::u64::MIN; };
13771
| ^^^^^^^^^^^^^ help: try this: `u64::min_value()`
13872

13973
error: using `MIN`
140-
--> $DIR/replace_consts.rs:37:17
74+
--> $DIR/replace_consts.rs:25:17
14175
|
14276
LL | { let foo = std::u128::MIN; };
14377
| ^^^^^^^^^^^^^^ help: try this: `u128::min_value()`
14478

14579
error: using `MAX`
146-
--> $DIR/replace_consts.rs:39:17
80+
--> $DIR/replace_consts.rs:27:17
14781
|
14882
LL | { let foo = std::isize::MAX; };
14983
| ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()`
15084

15185
error: using `MAX`
152-
--> $DIR/replace_consts.rs:40:17
86+
--> $DIR/replace_consts.rs:28:17
15387
|
15488
LL | { let foo = std::i8::MAX; };
15589
| ^^^^^^^^^^^^ help: try this: `i8::max_value()`
15690

15791
error: using `MAX`
158-
--> $DIR/replace_consts.rs:41:17
92+
--> $DIR/replace_consts.rs:29:17
15993
|
16094
LL | { let foo = std::i16::MAX; };
16195
| ^^^^^^^^^^^^^ help: try this: `i16::max_value()`
16296

16397
error: using `MAX`
164-
--> $DIR/replace_consts.rs:42:17
98+
--> $DIR/replace_consts.rs:30:17
16599
|
166100
LL | { let foo = std::i32::MAX; };
167101
| ^^^^^^^^^^^^^ help: try this: `i32::max_value()`
168102

169103
error: using `MAX`
170-
--> $DIR/replace_consts.rs:43:17
104+
--> $DIR/replace_consts.rs:31:17
171105
|
172106
LL | { let foo = std::i64::MAX; };
173107
| ^^^^^^^^^^^^^ help: try this: `i64::max_value()`
174108

175109
error: using `MAX`
176-
--> $DIR/replace_consts.rs:44:17
110+
--> $DIR/replace_consts.rs:32:17
177111
|
178112
LL | { let foo = std::i128::MAX; };
179113
| ^^^^^^^^^^^^^^ help: try this: `i128::max_value()`
180114

181115
error: using `MAX`
182-
--> $DIR/replace_consts.rs:45:17
116+
--> $DIR/replace_consts.rs:33:17
183117
|
184118
LL | { let foo = std::usize::MAX; };
185119
| ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()`
186120

187121
error: using `MAX`
188-
--> $DIR/replace_consts.rs:46:17
122+
--> $DIR/replace_consts.rs:34:17
189123
|
190124
LL | { let foo = std::u8::MAX; };
191125
| ^^^^^^^^^^^^ help: try this: `u8::max_value()`
192126

193127
error: using `MAX`
194-
--> $DIR/replace_consts.rs:47:17
128+
--> $DIR/replace_consts.rs:35:17
195129
|
196130
LL | { let foo = std::u16::MAX; };
197131
| ^^^^^^^^^^^^^ help: try this: `u16::max_value()`
198132

199133
error: using `MAX`
200-
--> $DIR/replace_consts.rs:48:17
134+
--> $DIR/replace_consts.rs:36:17
201135
|
202136
LL | { let foo = std::u32::MAX; };
203137
| ^^^^^^^^^^^^^ help: try this: `u32::max_value()`
204138

205139
error: using `MAX`
206-
--> $DIR/replace_consts.rs:49:17
140+
--> $DIR/replace_consts.rs:37:17
207141
|
208142
LL | { let foo = std::u64::MAX; };
209143
| ^^^^^^^^^^^^^ help: try this: `u64::max_value()`
210144

211145
error: using `MAX`
212-
--> $DIR/replace_consts.rs:50:17
146+
--> $DIR/replace_consts.rs:38:17
213147
|
214148
LL | { let foo = std::u128::MAX; };
215149
| ^^^^^^^^^^^^^^ help: try this: `u128::max_value()`
216150

217-
error: aborting due to 35 previous errors
151+
error: aborting due to 24 previous errors
218152

0 commit comments

Comments
 (0)