Skip to content

Commit f2e91ab

Browse files
committed
match syms, remove lint_reasons
1 parent 0c392d9 commit f2e91ab

6 files changed

+128
-128
lines changed

clippy_lints/src/legacy_numeric_constants.rs

+103-100
Original file line numberDiff line numberDiff line change
@@ -164,81 +164,83 @@ impl<'tcx> LateLintPass<'tcx> for LegacyNumericConstants {
164164
}
165165

166166
fn is_integer_module(cx: &LateContext<'_>, did: DefId) -> bool {
167-
[
168-
sym::isize_legacy_mod,
169-
sym::i128_legacy_mod,
170-
sym::i64_legacy_mod,
171-
sym::i32_legacy_mod,
172-
sym::i16_legacy_mod,
173-
sym::i8_legacy_mod,
174-
sym::usize_legacy_mod,
175-
sym::u128_legacy_mod,
176-
sym::u64_legacy_mod,
177-
sym::u32_legacy_mod,
178-
sym::u16_legacy_mod,
179-
sym::u8_legacy_mod,
180-
]
181-
.iter()
182-
.any(|&name| cx.tcx.is_diagnostic_item(name, did))
167+
matches!(
168+
cx.tcx.get_diagnostic_name(did),
169+
Some(
170+
sym::isize_legacy_mod
171+
| sym::i128_legacy_mod
172+
| sym::i64_legacy_mod
173+
| sym::i32_legacy_mod
174+
| sym::i16_legacy_mod
175+
| sym::i8_legacy_mod
176+
| sym::usize_legacy_mod
177+
| sym::u128_legacy_mod
178+
| sym::u64_legacy_mod
179+
| sym::u32_legacy_mod
180+
| sym::u16_legacy_mod
181+
| sym::u8_legacy_mod
182+
)
183+
)
183184
}
184185

185186
fn is_numeric_const(cx: &LateContext<'_>, did: DefId) -> bool {
186-
[
187-
sym::isize_legacy_const_max,
188-
sym::isize_legacy_const_min,
189-
sym::i128_legacy_const_max,
190-
sym::i128_legacy_const_min,
191-
sym::i16_legacy_const_max,
192-
sym::i16_legacy_const_min,
193-
sym::i32_legacy_const_max,
194-
sym::i32_legacy_const_min,
195-
sym::i64_legacy_const_max,
196-
sym::i64_legacy_const_min,
197-
sym::i8_legacy_const_max,
198-
sym::i8_legacy_const_min,
199-
sym::usize_legacy_const_max,
200-
sym::usize_legacy_const_min,
201-
sym::u128_legacy_const_max,
202-
sym::u128_legacy_const_min,
203-
sym::u16_legacy_const_max,
204-
sym::u16_legacy_const_min,
205-
sym::u32_legacy_const_max,
206-
sym::u32_legacy_const_min,
207-
sym::u64_legacy_const_max,
208-
sym::u64_legacy_const_min,
209-
sym::u8_legacy_const_max,
210-
sym::u8_legacy_const_min,
211-
sym::f32_legacy_const_digits,
212-
sym::f32_legacy_const_epsilon,
213-
sym::f32_legacy_const_infinity,
214-
sym::f32_legacy_const_mantissa_dig,
215-
sym::f32_legacy_const_max,
216-
sym::f32_legacy_const_max_10_exp,
217-
sym::f32_legacy_const_max_exp,
218-
sym::f32_legacy_const_min,
219-
sym::f32_legacy_const_min_10_exp,
220-
sym::f32_legacy_const_min_exp,
221-
sym::f32_legacy_const_min_positive,
222-
sym::f32_legacy_const_nan,
223-
sym::f32_legacy_const_neg_infinity,
224-
sym::f32_legacy_const_radix,
225-
sym::f64_legacy_const_digits,
226-
sym::f64_legacy_const_epsilon,
227-
sym::f64_legacy_const_infinity,
228-
sym::f64_legacy_const_mantissa_dig,
229-
sym::f64_legacy_const_max,
230-
sym::f64_legacy_const_max_10_exp,
231-
sym::f64_legacy_const_max_exp,
232-
sym::f64_legacy_const_min,
233-
sym::f64_legacy_const_min_10_exp,
234-
sym::f64_legacy_const_min_exp,
235-
sym::f64_legacy_const_min_positive,
236-
sym::f64_legacy_const_nan,
237-
sym::f64_legacy_const_neg_infinity,
238-
sym::f64_legacy_const_radix,
239-
]
240-
.iter()
241-
.any(|&name| cx.tcx.is_diagnostic_item(name, did))
187+
matches!(
188+
cx.tcx.get_diagnostic_name(did),
189+
Some(
190+
sym::isize_legacy_const_max
191+
| sym::isize_legacy_const_min
192+
| sym::i128_legacy_const_max
193+
| sym::i128_legacy_const_min
194+
| sym::i16_legacy_const_max
195+
| sym::i16_legacy_const_min
196+
| sym::i32_legacy_const_max
197+
| sym::i32_legacy_const_min
198+
| sym::i64_legacy_const_max
199+
| sym::i64_legacy_const_min
200+
| sym::i8_legacy_const_max
201+
| sym::i8_legacy_const_min
202+
| sym::usize_legacy_const_max
203+
| sym::usize_legacy_const_min
204+
| sym::u128_legacy_const_max
205+
| sym::u128_legacy_const_min
206+
| sym::u16_legacy_const_max
207+
| sym::u16_legacy_const_min
208+
| sym::u32_legacy_const_max
209+
| sym::u32_legacy_const_min
210+
| sym::u64_legacy_const_max
211+
| sym::u64_legacy_const_min
212+
| sym::u8_legacy_const_max
213+
| sym::u8_legacy_const_min
214+
| sym::f32_legacy_const_digits
215+
| sym::f32_legacy_const_epsilon
216+
| sym::f32_legacy_const_infinity
217+
| sym::f32_legacy_const_mantissa_dig
218+
| sym::f32_legacy_const_max
219+
| sym::f32_legacy_const_max_10_exp
220+
| sym::f32_legacy_const_max_exp
221+
| sym::f32_legacy_const_min
222+
| sym::f32_legacy_const_min_10_exp
223+
| sym::f32_legacy_const_min_exp
224+
| sym::f32_legacy_const_min_positive
225+
| sym::f32_legacy_const_nan
226+
| sym::f32_legacy_const_neg_infinity
227+
| sym::f32_legacy_const_radix
228+
| sym::f64_legacy_const_digits
229+
| sym::f64_legacy_const_epsilon
230+
| sym::f64_legacy_const_infinity
231+
| sym::f64_legacy_const_mantissa_dig
232+
| sym::f64_legacy_const_max
233+
| sym::f64_legacy_const_max_10_exp
234+
| sym::f64_legacy_const_max_exp
235+
| sym::f64_legacy_const_min
236+
| sym::f64_legacy_const_min_10_exp
237+
| sym::f64_legacy_const_min_exp
238+
| sym::f64_legacy_const_min_positive
239+
| sym::f64_legacy_const_nan
240+
| sym::f64_legacy_const_neg_infinity
241+
| sym::f64_legacy_const_radix
242+
)
243+
)
242244
}
243245

244246
// Whether path expression looks like `i32::MAX`
@@ -259,32 +261,33 @@ fn is_numeric_const_path_canonical(expr_path: &hir::Path<'_>, [mod_name, name]:
259261
}
260262

261263
fn is_integer_method(cx: &LateContext<'_>, did: DefId) -> bool {
262-
[
263-
sym::isize_legacy_fn_max_value,
264-
sym::isize_legacy_fn_min_value,
265-
sym::i128_legacy_fn_max_value,
266-
sym::i128_legacy_fn_min_value,
267-
sym::i16_legacy_fn_max_value,
268-
sym::i16_legacy_fn_min_value,
269-
sym::i32_legacy_fn_max_value,
270-
sym::i32_legacy_fn_min_value,
271-
sym::i64_legacy_fn_max_value,
272-
sym::i64_legacy_fn_min_value,
273-
sym::i8_legacy_fn_max_value,
274-
sym::i8_legacy_fn_min_value,
275-
sym::usize_legacy_fn_max_value,
276-
sym::usize_legacy_fn_min_value,
277-
sym::u128_legacy_fn_max_value,
278-
sym::u128_legacy_fn_min_value,
279-
sym::u16_legacy_fn_max_value,
280-
sym::u16_legacy_fn_min_value,
281-
sym::u32_legacy_fn_max_value,
282-
sym::u32_legacy_fn_min_value,
283-
sym::u64_legacy_fn_max_value,
284-
sym::u64_legacy_fn_min_value,
285-
sym::u8_legacy_fn_max_value,
286-
sym::u8_legacy_fn_min_value,
287-
]
288-
.iter()
289-
.any(|&name| cx.tcx.is_diagnostic_item(name, did))
264+
matches!(
265+
cx.tcx.get_diagnostic_name(did),
266+
Some(
267+
sym::isize_legacy_fn_max_value
268+
| sym::isize_legacy_fn_min_value
269+
| sym::i128_legacy_fn_max_value
270+
| sym::i128_legacy_fn_min_value
271+
| sym::i16_legacy_fn_max_value
272+
| sym::i16_legacy_fn_min_value
273+
| sym::i32_legacy_fn_max_value
274+
| sym::i32_legacy_fn_min_value
275+
| sym::i64_legacy_fn_max_value
276+
| sym::i64_legacy_fn_min_value
277+
| sym::i8_legacy_fn_max_value
278+
| sym::i8_legacy_fn_min_value
279+
| sym::usize_legacy_fn_max_value
280+
| sym::usize_legacy_fn_min_value
281+
| sym::u128_legacy_fn_max_value
282+
| sym::u128_legacy_fn_min_value
283+
| sym::u16_legacy_fn_max_value
284+
| sym::u16_legacy_fn_min_value
285+
| sym::u32_legacy_fn_max_value
286+
| sym::u32_legacy_fn_min_value
287+
| sym::u64_legacy_fn_max_value
288+
| sym::u64_legacy_fn_min_value
289+
| sym::u8_legacy_fn_max_value
290+
| sym::u8_legacy_fn_min_value
291+
)
292+
)
290293
}

tests/ui/legacy_numeric_constants.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@aux-build:proc_macros.rs
22
#![allow(clippy::no_effect, deprecated, unused)]
33
#![allow(clippy::legacy_numeric_constants)] // For imports.
4-
#![feature(lint_reasons)]
54

65
#[macro_use]
76
extern crate proc_macros;

tests/ui/legacy_numeric_constants.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@aux-build:proc_macros.rs
22
#![allow(clippy::no_effect, deprecated, unused)]
33
#![allow(clippy::legacy_numeric_constants)] // For imports.
4-
#![feature(lint_reasons)]
54

65
#[macro_use]
76
extern crate proc_macros;

tests/ui/legacy_numeric_constants.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: usage of a legacy numeric constant
2-
--> tests/ui/legacy_numeric_constants.rs:32:5
2+
--> tests/ui/legacy_numeric_constants.rs:31:5
33
|
44
LL | std::f32::EPSILON;
55
| ^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL | f32::EPSILON;
1212
| ~~~~~~~~~~~~
1313

1414
error: usage of a legacy numeric constant
15-
--> tests/ui/legacy_numeric_constants.rs:35:5
15+
--> tests/ui/legacy_numeric_constants.rs:34:5
1616
|
1717
LL | std::u8::MIN;
1818
| ^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | u8::MIN;
2323
| ~~~~~~~
2424

2525
error: usage of a legacy numeric constant
26-
--> tests/ui/legacy_numeric_constants.rs:38:5
26+
--> tests/ui/legacy_numeric_constants.rs:37:5
2727
|
2828
LL | std::usize::MIN;
2929
| ^^^^^^^^^^^^^^^
@@ -34,7 +34,7 @@ LL | usize::MIN;
3434
| ~~~~~~~~~~
3535

3636
error: usage of a legacy numeric constant
37-
--> tests/ui/legacy_numeric_constants.rs:41:5
37+
--> tests/ui/legacy_numeric_constants.rs:40:5
3838
|
3939
LL | std::u32::MAX;
4040
| ^^^^^^^^^^^^^
@@ -45,7 +45,7 @@ LL | u32::MAX;
4545
| ~~~~~~~~
4646

4747
error: usage of a legacy numeric constant
48-
--> tests/ui/legacy_numeric_constants.rs:44:5
48+
--> tests/ui/legacy_numeric_constants.rs:43:5
4949
|
5050
LL | core::u32::MAX;
5151
| ^^^^^^^^^^^^^^
@@ -56,7 +56,7 @@ LL | u32::MAX;
5656
| ~~~~~~~~
5757

5858
error: usage of a legacy numeric constant
59-
--> tests/ui/legacy_numeric_constants.rs:47:5
59+
--> tests/ui/legacy_numeric_constants.rs:46:5
6060
|
6161
LL | MAX;
6262
| ^^^
@@ -67,7 +67,7 @@ LL | u32::MAX;
6767
| ~~~~~~~~
6868

6969
error: usage of a legacy numeric method
70-
--> tests/ui/legacy_numeric_constants.rs:50:10
70+
--> tests/ui/legacy_numeric_constants.rs:49:10
7171
|
7272
LL | i32::max_value();
7373
| ^^^^^^^^^^^
@@ -78,7 +78,7 @@ LL | i32::MAX;
7878
| ~~~
7979

8080
error: usage of a legacy numeric method
81-
--> tests/ui/legacy_numeric_constants.rs:53:9
81+
--> tests/ui/legacy_numeric_constants.rs:52:9
8282
|
8383
LL | u8::max_value();
8484
| ^^^^^^^^^^^
@@ -89,7 +89,7 @@ LL | u8::MAX;
8989
| ~~~
9090

9191
error: usage of a legacy numeric method
92-
--> tests/ui/legacy_numeric_constants.rs:56:9
92+
--> tests/ui/legacy_numeric_constants.rs:55:9
9393
|
9494
LL | u8::min_value();
9595
| ^^^^^^^^^^^
@@ -100,7 +100,7 @@ LL | u8::MIN;
100100
| ~~~
101101

102102
error: usage of a legacy numeric constant
103-
--> tests/ui/legacy_numeric_constants.rs:59:5
103+
--> tests/ui/legacy_numeric_constants.rs:58:5
104104
|
105105
LL | ::std::u8::MIN;
106106
| ^^^^^^^^^^^^^^
@@ -111,7 +111,7 @@ LL | u8::MIN;
111111
| ~~~~~~~
112112

113113
error: usage of a legacy numeric method
114-
--> tests/ui/legacy_numeric_constants.rs:62:27
114+
--> tests/ui/legacy_numeric_constants.rs:61:27
115115
|
116116
LL | ::std::primitive::u8::min_value();
117117
| ^^^^^^^^^^^
@@ -122,7 +122,7 @@ LL | ::std::primitive::u8::MIN;
122122
| ~~~
123123

124124
error: usage of a legacy numeric method
125-
--> tests/ui/legacy_numeric_constants.rs:65:26
125+
--> tests/ui/legacy_numeric_constants.rs:64:26
126126
|
127127
LL | std::primitive::i32::max_value();
128128
| ^^^^^^^^^^^
@@ -133,7 +133,7 @@ LL | std::primitive::i32::MAX;
133133
| ~~~
134134

135135
error: usage of a legacy numeric constant
136-
--> tests/ui/legacy_numeric_constants.rs:68:5
136+
--> tests/ui/legacy_numeric_constants.rs:67:5
137137
|
138138
LL | self::a::u128::MAX;
139139
| ^^^^^^^^^^^^^^^^^^
@@ -144,7 +144,7 @@ LL | u128::MAX;
144144
| ~~~~~~~~~
145145

146146
error: usage of a legacy numeric constant
147-
--> tests/ui/legacy_numeric_constants.rs:18:25
147+
--> tests/ui/legacy_numeric_constants.rs:17:25
148148
|
149149
LL | let x = std::u64::MAX;
150150
| ^^^^^^^^^^^^^
@@ -159,7 +159,7 @@ LL | let x = u64::MAX;
159159
| ~~~~~~~~
160160

161161
error: usage of a legacy numeric constant
162-
--> tests/ui/legacy_numeric_constants.rs:82:14
162+
--> tests/ui/legacy_numeric_constants.rs:81:14
163163
|
164164
LL | [(0, "", std::i128::MAX)];
165165
| ^^^^^^^^^^^^^^
@@ -170,7 +170,7 @@ LL | [(0, "", i128::MAX)];
170170
| ~~~~~~~~~
171171

172172
error: usage of a legacy numeric constant
173-
--> tests/ui/legacy_numeric_constants.rs:116:5
173+
--> tests/ui/legacy_numeric_constants.rs:115:5
174174
|
175175
LL | std::u32::MAX;
176176
| ^^^^^^^^^^^^^

tests/ui/legacy_numeric_constants_unfixable.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//@aux-build:proc_macros.rs
33
#![allow(clippy::no_effect, deprecated, unused)]
44
#![warn(clippy::legacy_numeric_constants)]
5-
#![feature(lint_reasons)]
65

76
#[macro_use]
87
extern crate proc_macros;

0 commit comments

Comments
 (0)