Skip to content

Commit 2d11a44

Browse files
committed
Add run-rustfix to replace_const test
1 parent aa1793e commit 2d11a44

File tree

3 files changed

+138
-37
lines changed

3 files changed

+138
-37
lines changed

tests/ui/replace_consts.fixed

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// run-rustfix
2+
#![feature(integer_atomics)]
3+
#![allow(unused_variables, clippy::blacklisted_name)]
4+
#![deny(clippy::replace_consts)]
5+
6+
use std::sync::atomic::*;
7+
use std::sync::{Once, ONCE_INIT};
8+
9+
#[rustfmt::skip]
10+
fn bad() {
11+
// Once
12+
{ 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); };
25+
// Min
26+
{ let foo = isize::min_value(); };
27+
{ let foo = i8::min_value(); };
28+
{ let foo = i16::min_value(); };
29+
{ let foo = i32::min_value(); };
30+
{ let foo = i64::min_value(); };
31+
{ let foo = i128::min_value(); };
32+
{ let foo = usize::min_value(); };
33+
{ let foo = u8::min_value(); };
34+
{ let foo = u16::min_value(); };
35+
{ let foo = u32::min_value(); };
36+
{ let foo = u64::min_value(); };
37+
{ let foo = u128::min_value(); };
38+
// Max
39+
{ let foo = isize::max_value(); };
40+
{ let foo = i8::max_value(); };
41+
{ let foo = i16::max_value(); };
42+
{ let foo = i32::max_value(); };
43+
{ let foo = i64::max_value(); };
44+
{ let foo = i128::max_value(); };
45+
{ let foo = usize::max_value(); };
46+
{ let foo = u8::max_value(); };
47+
{ let foo = u16::max_value(); };
48+
{ let foo = u32::max_value(); };
49+
{ let foo = u64::max_value(); };
50+
{ let foo = u128::max_value(); };
51+
}
52+
53+
#[rustfmt::skip]
54+
fn good() {
55+
// Once
56+
{ let foo = Once::new(); };
57+
// Atomic
58+
{ let foo = AtomicBool::new(false); };
59+
{ let foo = AtomicIsize::new(0); };
60+
{ let foo = AtomicI8::new(0); };
61+
{ let foo = AtomicI16::new(0); };
62+
{ let foo = AtomicI32::new(0); };
63+
{ let foo = AtomicI64::new(0); };
64+
{ let foo = AtomicUsize::new(0); };
65+
{ let foo = AtomicU8::new(0); };
66+
{ let foo = AtomicU16::new(0); };
67+
{ let foo = AtomicU32::new(0); };
68+
{ let foo = AtomicU64::new(0); };
69+
// Min
70+
{ let foo = isize::min_value(); };
71+
{ let foo = i8::min_value(); };
72+
{ let foo = i16::min_value(); };
73+
{ let foo = i32::min_value(); };
74+
{ let foo = i64::min_value(); };
75+
{ let foo = i128::min_value(); };
76+
{ let foo = usize::min_value(); };
77+
{ let foo = u8::min_value(); };
78+
{ let foo = u16::min_value(); };
79+
{ let foo = u32::min_value(); };
80+
{ let foo = u64::min_value(); };
81+
{ let foo = u128::min_value(); };
82+
// Max
83+
{ let foo = isize::max_value(); };
84+
{ let foo = i8::max_value(); };
85+
{ let foo = i16::max_value(); };
86+
{ let foo = i32::max_value(); };
87+
{ let foo = i64::max_value(); };
88+
{ let foo = i128::max_value(); };
89+
{ let foo = usize::max_value(); };
90+
{ let foo = u8::max_value(); };
91+
{ let foo = u16::max_value(); };
92+
{ let foo = u32::max_value(); };
93+
{ let foo = u64::max_value(); };
94+
{ let foo = u128::max_value(); };
95+
}
96+
97+
fn main() {
98+
bad();
99+
good();
100+
}

tests/ui/replace_consts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
// run-rustfix
12
#![feature(integer_atomics)]
2-
#![allow(clippy::blacklisted_name)]
3+
#![allow(unused_variables, clippy::blacklisted_name)]
34
#![deny(clippy::replace_consts)]
45

56
use std::sync::atomic::*;

tests/ui/replace_consts.stderr

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,215 @@
11
error: using `ATOMIC_BOOL_INIT`
2-
--> $DIR/replace_consts.rs:13:17
2+
--> $DIR/replace_consts.rs:14:17
33
|
44
LL | { let foo = ATOMIC_BOOL_INIT; };
55
| ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)`
66
|
77
note: lint level defined here
8-
--> $DIR/replace_consts.rs:3:9
8+
--> $DIR/replace_consts.rs:4:9
99
|
1010
LL | #![deny(clippy::replace_consts)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: using `ATOMIC_ISIZE_INIT`
14-
--> $DIR/replace_consts.rs:14:17
14+
--> $DIR/replace_consts.rs:15:17
1515
|
1616
LL | { let foo = ATOMIC_ISIZE_INIT; };
1717
| ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)`
1818

1919
error: using `ATOMIC_I8_INIT`
20-
--> $DIR/replace_consts.rs:15:17
20+
--> $DIR/replace_consts.rs:16:17
2121
|
2222
LL | { let foo = ATOMIC_I8_INIT; };
2323
| ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)`
2424

2525
error: using `ATOMIC_I16_INIT`
26-
--> $DIR/replace_consts.rs:16:17
26+
--> $DIR/replace_consts.rs:17:17
2727
|
2828
LL | { let foo = ATOMIC_I16_INIT; };
2929
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)`
3030

3131
error: using `ATOMIC_I32_INIT`
32-
--> $DIR/replace_consts.rs:17:17
32+
--> $DIR/replace_consts.rs:18:17
3333
|
3434
LL | { let foo = ATOMIC_I32_INIT; };
3535
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)`
3636

3737
error: using `ATOMIC_I64_INIT`
38-
--> $DIR/replace_consts.rs:18:17
38+
--> $DIR/replace_consts.rs:19:17
3939
|
4040
LL | { let foo = ATOMIC_I64_INIT; };
4141
| ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)`
4242

4343
error: using `ATOMIC_USIZE_INIT`
44-
--> $DIR/replace_consts.rs:19:17
44+
--> $DIR/replace_consts.rs:20:17
4545
|
4646
LL | { let foo = ATOMIC_USIZE_INIT; };
4747
| ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)`
4848

4949
error: using `ATOMIC_U8_INIT`
50-
--> $DIR/replace_consts.rs:20:17
50+
--> $DIR/replace_consts.rs:21:17
5151
|
5252
LL | { let foo = ATOMIC_U8_INIT; };
5353
| ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)`
5454

5555
error: using `ATOMIC_U16_INIT`
56-
--> $DIR/replace_consts.rs:21:17
56+
--> $DIR/replace_consts.rs:22:17
5757
|
5858
LL | { let foo = ATOMIC_U16_INIT; };
5959
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)`
6060

6161
error: using `ATOMIC_U32_INIT`
62-
--> $DIR/replace_consts.rs:22:17
62+
--> $DIR/replace_consts.rs:23:17
6363
|
6464
LL | { let foo = ATOMIC_U32_INIT; };
6565
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)`
6666

6767
error: using `ATOMIC_U64_INIT`
68-
--> $DIR/replace_consts.rs:23:17
68+
--> $DIR/replace_consts.rs:24:17
6969
|
7070
LL | { let foo = ATOMIC_U64_INIT; };
7171
| ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)`
7272

7373
error: using `MIN`
74-
--> $DIR/replace_consts.rs:25:17
74+
--> $DIR/replace_consts.rs:26:17
7575
|
7676
LL | { let foo = std::isize::MIN; };
7777
| ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()`
7878

7979
error: using `MIN`
80-
--> $DIR/replace_consts.rs:26:17
80+
--> $DIR/replace_consts.rs:27:17
8181
|
8282
LL | { let foo = std::i8::MIN; };
8383
| ^^^^^^^^^^^^ help: try this: `i8::min_value()`
8484

8585
error: using `MIN`
86-
--> $DIR/replace_consts.rs:27:17
86+
--> $DIR/replace_consts.rs:28:17
8787
|
8888
LL | { let foo = std::i16::MIN; };
8989
| ^^^^^^^^^^^^^ help: try this: `i16::min_value()`
9090

9191
error: using `MIN`
92-
--> $DIR/replace_consts.rs:28:17
92+
--> $DIR/replace_consts.rs:29:17
9393
|
9494
LL | { let foo = std::i32::MIN; };
9595
| ^^^^^^^^^^^^^ help: try this: `i32::min_value()`
9696

9797
error: using `MIN`
98-
--> $DIR/replace_consts.rs:29:17
98+
--> $DIR/replace_consts.rs:30:17
9999
|
100100
LL | { let foo = std::i64::MIN; };
101101
| ^^^^^^^^^^^^^ help: try this: `i64::min_value()`
102102

103103
error: using `MIN`
104-
--> $DIR/replace_consts.rs:30:17
104+
--> $DIR/replace_consts.rs:31:17
105105
|
106106
LL | { let foo = std::i128::MIN; };
107107
| ^^^^^^^^^^^^^^ help: try this: `i128::min_value()`
108108

109109
error: using `MIN`
110-
--> $DIR/replace_consts.rs:31:17
110+
--> $DIR/replace_consts.rs:32:17
111111
|
112112
LL | { let foo = std::usize::MIN; };
113113
| ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()`
114114

115115
error: using `MIN`
116-
--> $DIR/replace_consts.rs:32:17
116+
--> $DIR/replace_consts.rs:33:17
117117
|
118118
LL | { let foo = std::u8::MIN; };
119119
| ^^^^^^^^^^^^ help: try this: `u8::min_value()`
120120

121121
error: using `MIN`
122-
--> $DIR/replace_consts.rs:33:17
122+
--> $DIR/replace_consts.rs:34:17
123123
|
124124
LL | { let foo = std::u16::MIN; };
125125
| ^^^^^^^^^^^^^ help: try this: `u16::min_value()`
126126

127127
error: using `MIN`
128-
--> $DIR/replace_consts.rs:34:17
128+
--> $DIR/replace_consts.rs:35:17
129129
|
130130
LL | { let foo = std::u32::MIN; };
131131
| ^^^^^^^^^^^^^ help: try this: `u32::min_value()`
132132

133133
error: using `MIN`
134-
--> $DIR/replace_consts.rs:35:17
134+
--> $DIR/replace_consts.rs:36:17
135135
|
136136
LL | { let foo = std::u64::MIN; };
137137
| ^^^^^^^^^^^^^ help: try this: `u64::min_value()`
138138

139139
error: using `MIN`
140-
--> $DIR/replace_consts.rs:36:17
140+
--> $DIR/replace_consts.rs:37:17
141141
|
142142
LL | { let foo = std::u128::MIN; };
143143
| ^^^^^^^^^^^^^^ help: try this: `u128::min_value()`
144144

145145
error: using `MAX`
146-
--> $DIR/replace_consts.rs:38:17
146+
--> $DIR/replace_consts.rs:39:17
147147
|
148148
LL | { let foo = std::isize::MAX; };
149149
| ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()`
150150

151151
error: using `MAX`
152-
--> $DIR/replace_consts.rs:39:17
152+
--> $DIR/replace_consts.rs:40:17
153153
|
154154
LL | { let foo = std::i8::MAX; };
155155
| ^^^^^^^^^^^^ help: try this: `i8::max_value()`
156156

157157
error: using `MAX`
158-
--> $DIR/replace_consts.rs:40:17
158+
--> $DIR/replace_consts.rs:41:17
159159
|
160160
LL | { let foo = std::i16::MAX; };
161161
| ^^^^^^^^^^^^^ help: try this: `i16::max_value()`
162162

163163
error: using `MAX`
164-
--> $DIR/replace_consts.rs:41:17
164+
--> $DIR/replace_consts.rs:42:17
165165
|
166166
LL | { let foo = std::i32::MAX; };
167167
| ^^^^^^^^^^^^^ help: try this: `i32::max_value()`
168168

169169
error: using `MAX`
170-
--> $DIR/replace_consts.rs:42:17
170+
--> $DIR/replace_consts.rs:43:17
171171
|
172172
LL | { let foo = std::i64::MAX; };
173173
| ^^^^^^^^^^^^^ help: try this: `i64::max_value()`
174174

175175
error: using `MAX`
176-
--> $DIR/replace_consts.rs:43:17
176+
--> $DIR/replace_consts.rs:44:17
177177
|
178178
LL | { let foo = std::i128::MAX; };
179179
| ^^^^^^^^^^^^^^ help: try this: `i128::max_value()`
180180

181181
error: using `MAX`
182-
--> $DIR/replace_consts.rs:44:17
182+
--> $DIR/replace_consts.rs:45:17
183183
|
184184
LL | { let foo = std::usize::MAX; };
185185
| ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()`
186186

187187
error: using `MAX`
188-
--> $DIR/replace_consts.rs:45:17
188+
--> $DIR/replace_consts.rs:46:17
189189
|
190190
LL | { let foo = std::u8::MAX; };
191191
| ^^^^^^^^^^^^ help: try this: `u8::max_value()`
192192

193193
error: using `MAX`
194-
--> $DIR/replace_consts.rs:46:17
194+
--> $DIR/replace_consts.rs:47:17
195195
|
196196
LL | { let foo = std::u16::MAX; };
197197
| ^^^^^^^^^^^^^ help: try this: `u16::max_value()`
198198

199199
error: using `MAX`
200-
--> $DIR/replace_consts.rs:47:17
200+
--> $DIR/replace_consts.rs:48:17
201201
|
202202
LL | { let foo = std::u32::MAX; };
203203
| ^^^^^^^^^^^^^ help: try this: `u32::max_value()`
204204

205205
error: using `MAX`
206-
--> $DIR/replace_consts.rs:48:17
206+
--> $DIR/replace_consts.rs:49:17
207207
|
208208
LL | { let foo = std::u64::MAX; };
209209
| ^^^^^^^^^^^^^ help: try this: `u64::max_value()`
210210

211211
error: using `MAX`
212-
--> $DIR/replace_consts.rs:49:17
212+
--> $DIR/replace_consts.rs:50:17
213213
|
214214
LL | { let foo = std::u128::MAX; };
215215
| ^^^^^^^^^^^^^^ help: try this: `u128::max_value()`

0 commit comments

Comments
 (0)