From f2e91ab1b9aaab23b81fc5ea5de43367cb9b9e6d Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Sun, 24 Mar 2024 10:16:45 -0600
Subject: [PATCH] match syms, remove lint_reasons
---
clippy_lints/src/legacy_numeric_constants.rs | 203 +++++++++---------
tests/ui/legacy_numeric_constants.fixed | 1 -
tests/ui/legacy_numeric_constants.rs | 1 -
tests/ui/legacy_numeric_constants.stderr | 32 +--
.../ui/legacy_numeric_constants_unfixable.rs | 1 -
.../legacy_numeric_constants_unfixable.stderr | 18 +-
6 files changed, 128 insertions(+), 128 deletions(-)
diff --git a/clippy_lints/src/legacy_numeric_constants.rs b/clippy_lints/src/legacy_numeric_constants.rs
index a325b4d5493..c5f1afe68c3 100644
--- a/clippy_lints/src/legacy_numeric_constants.rs
+++ b/clippy_lints/src/legacy_numeric_constants.rs
@@ -164,81 +164,83 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx rustc_hir::Expr<'tc
}
fn is_integer_module(cx: &LateContext<'_>, did: DefId) -> bool {
- [
- sym::isize_legacy_mod,
- sym::i128_legacy_mod,
- sym::i64_legacy_mod,
- sym::i32_legacy_mod,
- sym::i16_legacy_mod,
- sym::i8_legacy_mod,
- sym::usize_legacy_mod,
- sym::u128_legacy_mod,
- sym::u64_legacy_mod,
- sym::u32_legacy_mod,
- sym::u16_legacy_mod,
- sym::u8_legacy_mod,
- ]
- .iter()
- .any(|&name| cx.tcx.is_diagnostic_item(name, did))
+ matches!(
+ cx.tcx.get_diagnostic_name(did),
+ Some(
+ sym::isize_legacy_mod
+ | sym::i128_legacy_mod
+ | sym::i64_legacy_mod
+ | sym::i32_legacy_mod
+ | sym::i16_legacy_mod
+ | sym::i8_legacy_mod
+ | sym::usize_legacy_mod
+ | sym::u128_legacy_mod
+ | sym::u64_legacy_mod
+ | sym::u32_legacy_mod
+ | sym::u16_legacy_mod
+ | sym::u8_legacy_mod
+ )
+ )
}
fn is_numeric_const(cx: &LateContext<'_>, did: DefId) -> bool {
- [
- sym::isize_legacy_const_max,
- sym::isize_legacy_const_min,
- sym::i128_legacy_const_max,
- sym::i128_legacy_const_min,
- sym::i16_legacy_const_max,
- sym::i16_legacy_const_min,
- sym::i32_legacy_const_max,
- sym::i32_legacy_const_min,
- sym::i64_legacy_const_max,
- sym::i64_legacy_const_min,
- sym::i8_legacy_const_max,
- sym::i8_legacy_const_min,
- sym::usize_legacy_const_max,
- sym::usize_legacy_const_min,
- sym::u128_legacy_const_max,
- sym::u128_legacy_const_min,
- sym::u16_legacy_const_max,
- sym::u16_legacy_const_min,
- sym::u32_legacy_const_max,
- sym::u32_legacy_const_min,
- sym::u64_legacy_const_max,
- sym::u64_legacy_const_min,
- sym::u8_legacy_const_max,
- sym::u8_legacy_const_min,
- sym::f32_legacy_const_digits,
- sym::f32_legacy_const_epsilon,
- sym::f32_legacy_const_infinity,
- sym::f32_legacy_const_mantissa_dig,
- sym::f32_legacy_const_max,
- sym::f32_legacy_const_max_10_exp,
- sym::f32_legacy_const_max_exp,
- sym::f32_legacy_const_min,
- sym::f32_legacy_const_min_10_exp,
- sym::f32_legacy_const_min_exp,
- sym::f32_legacy_const_min_positive,
- sym::f32_legacy_const_nan,
- sym::f32_legacy_const_neg_infinity,
- sym::f32_legacy_const_radix,
- sym::f64_legacy_const_digits,
- sym::f64_legacy_const_epsilon,
- sym::f64_legacy_const_infinity,
- sym::f64_legacy_const_mantissa_dig,
- sym::f64_legacy_const_max,
- sym::f64_legacy_const_max_10_exp,
- sym::f64_legacy_const_max_exp,
- sym::f64_legacy_const_min,
- sym::f64_legacy_const_min_10_exp,
- sym::f64_legacy_const_min_exp,
- sym::f64_legacy_const_min_positive,
- sym::f64_legacy_const_nan,
- sym::f64_legacy_const_neg_infinity,
- sym::f64_legacy_const_radix,
- ]
- .iter()
- .any(|&name| cx.tcx.is_diagnostic_item(name, did))
+ matches!(
+ cx.tcx.get_diagnostic_name(did),
+ Some(
+ sym::isize_legacy_const_max
+ | sym::isize_legacy_const_min
+ | sym::i128_legacy_const_max
+ | sym::i128_legacy_const_min
+ | sym::i16_legacy_const_max
+ | sym::i16_legacy_const_min
+ | sym::i32_legacy_const_max
+ | sym::i32_legacy_const_min
+ | sym::i64_legacy_const_max
+ | sym::i64_legacy_const_min
+ | sym::i8_legacy_const_max
+ | sym::i8_legacy_const_min
+ | sym::usize_legacy_const_max
+ | sym::usize_legacy_const_min
+ | sym::u128_legacy_const_max
+ | sym::u128_legacy_const_min
+ | sym::u16_legacy_const_max
+ | sym::u16_legacy_const_min
+ | sym::u32_legacy_const_max
+ | sym::u32_legacy_const_min
+ | sym::u64_legacy_const_max
+ | sym::u64_legacy_const_min
+ | sym::u8_legacy_const_max
+ | sym::u8_legacy_const_min
+ | sym::f32_legacy_const_digits
+ | sym::f32_legacy_const_epsilon
+ | sym::f32_legacy_const_infinity
+ | sym::f32_legacy_const_mantissa_dig
+ | sym::f32_legacy_const_max
+ | sym::f32_legacy_const_max_10_exp
+ | sym::f32_legacy_const_max_exp
+ | sym::f32_legacy_const_min
+ | sym::f32_legacy_const_min_10_exp
+ | sym::f32_legacy_const_min_exp
+ | sym::f32_legacy_const_min_positive
+ | sym::f32_legacy_const_nan
+ | sym::f32_legacy_const_neg_infinity
+ | sym::f32_legacy_const_radix
+ | sym::f64_legacy_const_digits
+ | sym::f64_legacy_const_epsilon
+ | sym::f64_legacy_const_infinity
+ | sym::f64_legacy_const_mantissa_dig
+ | sym::f64_legacy_const_max
+ | sym::f64_legacy_const_max_10_exp
+ | sym::f64_legacy_const_max_exp
+ | sym::f64_legacy_const_min
+ | sym::f64_legacy_const_min_10_exp
+ | sym::f64_legacy_const_min_exp
+ | sym::f64_legacy_const_min_positive
+ | sym::f64_legacy_const_nan
+ | sym::f64_legacy_const_neg_infinity
+ | sym::f64_legacy_const_radix
+ )
+ )
}
// Whether path expression looks like `i32::MAX`
@@ -259,32 +261,33 @@ fn is_numeric_const(cx: &LateContext<'_>, did: DefId) -> bool {
}
fn is_integer_method(cx: &LateContext<'_>, did: DefId) -> bool {
- [
- sym::isize_legacy_fn_max_value,
- sym::isize_legacy_fn_min_value,
- sym::i128_legacy_fn_max_value,
- sym::i128_legacy_fn_min_value,
- sym::i16_legacy_fn_max_value,
- sym::i16_legacy_fn_min_value,
- sym::i32_legacy_fn_max_value,
- sym::i32_legacy_fn_min_value,
- sym::i64_legacy_fn_max_value,
- sym::i64_legacy_fn_min_value,
- sym::i8_legacy_fn_max_value,
- sym::i8_legacy_fn_min_value,
- sym::usize_legacy_fn_max_value,
- sym::usize_legacy_fn_min_value,
- sym::u128_legacy_fn_max_value,
- sym::u128_legacy_fn_min_value,
- sym::u16_legacy_fn_max_value,
- sym::u16_legacy_fn_min_value,
- sym::u32_legacy_fn_max_value,
- sym::u32_legacy_fn_min_value,
- sym::u64_legacy_fn_max_value,
- sym::u64_legacy_fn_min_value,
- sym::u8_legacy_fn_max_value,
- sym::u8_legacy_fn_min_value,
- ]
- .iter()
- .any(|&name| cx.tcx.is_diagnostic_item(name, did))
+ matches!(
+ cx.tcx.get_diagnostic_name(did),
+ Some(
+ sym::isize_legacy_fn_max_value
+ | sym::isize_legacy_fn_min_value
+ | sym::i128_legacy_fn_max_value
+ | sym::i128_legacy_fn_min_value
+ | sym::i16_legacy_fn_max_value
+ | sym::i16_legacy_fn_min_value
+ | sym::i32_legacy_fn_max_value
+ | sym::i32_legacy_fn_min_value
+ | sym::i64_legacy_fn_max_value
+ | sym::i64_legacy_fn_min_value
+ | sym::i8_legacy_fn_max_value
+ | sym::i8_legacy_fn_min_value
+ | sym::usize_legacy_fn_max_value
+ | sym::usize_legacy_fn_min_value
+ | sym::u128_legacy_fn_max_value
+ | sym::u128_legacy_fn_min_value
+ | sym::u16_legacy_fn_max_value
+ | sym::u16_legacy_fn_min_value
+ | sym::u32_legacy_fn_max_value
+ | sym::u32_legacy_fn_min_value
+ | sym::u64_legacy_fn_max_value
+ | sym::u64_legacy_fn_min_value
+ | sym::u8_legacy_fn_max_value
+ | sym::u8_legacy_fn_min_value
+ )
+ )
}
diff --git a/tests/ui/legacy_numeric_constants.fixed b/tests/ui/legacy_numeric_constants.fixed
index 31a6c1b3944..a6ef8f8c119 100644
--- a/tests/ui/legacy_numeric_constants.fixed
+++ b/tests/ui/legacy_numeric_constants.fixed
@@ -1,7 +1,6 @@
//@aux-build:proc_macros.rs
#![allow(clippy::no_effect, deprecated, unused)]
#![allow(clippy::legacy_numeric_constants)] // For imports.
-#![feature(lint_reasons)]
#[macro_use]
extern crate proc_macros;
diff --git a/tests/ui/legacy_numeric_constants.rs b/tests/ui/legacy_numeric_constants.rs
index e4dd3d5896f..cd633545372 100644
--- a/tests/ui/legacy_numeric_constants.rs
+++ b/tests/ui/legacy_numeric_constants.rs
@@ -1,7 +1,6 @@
//@aux-build:proc_macros.rs
#![allow(clippy::no_effect, deprecated, unused)]
#![allow(clippy::legacy_numeric_constants)] // For imports.
-#![feature(lint_reasons)]
#[macro_use]
extern crate proc_macros;
diff --git a/tests/ui/legacy_numeric_constants.stderr b/tests/ui/legacy_numeric_constants.stderr
index af9b003ed54..267b9ac8e4d 100644
--- a/tests/ui/legacy_numeric_constants.stderr
+++ b/tests/ui/legacy_numeric_constants.stderr
@@ -1,5 +1,5 @@
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:32:5
+ --> tests/ui/legacy_numeric_constants.rs:31:5
|
LL | std::f32::EPSILON;
| ^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL | f32::EPSILON;
| ~~~~~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:35:5
+ --> tests/ui/legacy_numeric_constants.rs:34:5
|
LL | std::u8::MIN;
| ^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL | u8::MIN;
| ~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:38:5
+ --> tests/ui/legacy_numeric_constants.rs:37:5
|
LL | std::usize::MIN;
| ^^^^^^^^^^^^^^^
@@ -34,7 +34,7 @@ LL | usize::MIN;
| ~~~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:41:5
+ --> tests/ui/legacy_numeric_constants.rs:40:5
|
LL | std::u32::MAX;
| ^^^^^^^^^^^^^
@@ -45,7 +45,7 @@ LL | u32::MAX;
| ~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:44:5
+ --> tests/ui/legacy_numeric_constants.rs:43:5
|
LL | core::u32::MAX;
| ^^^^^^^^^^^^^^
@@ -56,7 +56,7 @@ LL | u32::MAX;
| ~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:47:5
+ --> tests/ui/legacy_numeric_constants.rs:46:5
|
LL | MAX;
| ^^^
@@ -67,7 +67,7 @@ LL | u32::MAX;
| ~~~~~~~~
error: usage of a legacy numeric method
- --> tests/ui/legacy_numeric_constants.rs:50:10
+ --> tests/ui/legacy_numeric_constants.rs:49:10
|
LL | i32::max_value();
| ^^^^^^^^^^^
@@ -78,7 +78,7 @@ LL | i32::MAX;
| ~~~
error: usage of a legacy numeric method
- --> tests/ui/legacy_numeric_constants.rs:53:9
+ --> tests/ui/legacy_numeric_constants.rs:52:9
|
LL | u8::max_value();
| ^^^^^^^^^^^
@@ -89,7 +89,7 @@ LL | u8::MAX;
| ~~~
error: usage of a legacy numeric method
- --> tests/ui/legacy_numeric_constants.rs:56:9
+ --> tests/ui/legacy_numeric_constants.rs:55:9
|
LL | u8::min_value();
| ^^^^^^^^^^^
@@ -100,7 +100,7 @@ LL | u8::MIN;
| ~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:59:5
+ --> tests/ui/legacy_numeric_constants.rs:58:5
|
LL | ::std::u8::MIN;
| ^^^^^^^^^^^^^^
@@ -111,7 +111,7 @@ LL | u8::MIN;
| ~~~~~~~
error: usage of a legacy numeric method
- --> tests/ui/legacy_numeric_constants.rs:62:27
+ --> tests/ui/legacy_numeric_constants.rs:61:27
|
LL | ::std::primitive::u8::min_value();
| ^^^^^^^^^^^
@@ -122,7 +122,7 @@ LL | ::std::primitive::u8::MIN;
| ~~~
error: usage of a legacy numeric method
- --> tests/ui/legacy_numeric_constants.rs:65:26
+ --> tests/ui/legacy_numeric_constants.rs:64:26
|
LL | std::primitive::i32::max_value();
| ^^^^^^^^^^^
@@ -133,7 +133,7 @@ LL | std::primitive::i32::MAX;
| ~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:68:5
+ --> tests/ui/legacy_numeric_constants.rs:67:5
|
LL | self::a::u128::MAX;
| ^^^^^^^^^^^^^^^^^^
@@ -144,7 +144,7 @@ LL | u128::MAX;
| ~~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:18:25
+ --> tests/ui/legacy_numeric_constants.rs:17:25
|
LL | let x = std::u64::MAX;
| ^^^^^^^^^^^^^
@@ -159,7 +159,7 @@ LL | let x = u64::MAX;
| ~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:82:14
+ --> tests/ui/legacy_numeric_constants.rs:81:14
|
LL | [(0, "", std::i128::MAX)];
| ^^^^^^^^^^^^^^
@@ -170,7 +170,7 @@ LL | [(0, "", i128::MAX)];
| ~~~~~~~~~
error: usage of a legacy numeric constant
- --> tests/ui/legacy_numeric_constants.rs:116:5
+ --> tests/ui/legacy_numeric_constants.rs:115:5
|
LL | std::u32::MAX;
| ^^^^^^^^^^^^^
diff --git a/tests/ui/legacy_numeric_constants_unfixable.rs b/tests/ui/legacy_numeric_constants_unfixable.rs
index 228ebdd6a6c..86738ede210 100644
--- a/tests/ui/legacy_numeric_constants_unfixable.rs
+++ b/tests/ui/legacy_numeric_constants_unfixable.rs
@@ -2,7 +2,6 @@
//@aux-build:proc_macros.rs
#![allow(clippy::no_effect, deprecated, unused)]
#![warn(clippy::legacy_numeric_constants)]
-#![feature(lint_reasons)]
#[macro_use]
extern crate proc_macros;
diff --git a/tests/ui/legacy_numeric_constants_unfixable.stderr b/tests/ui/legacy_numeric_constants_unfixable.stderr
index 96e6c9ef975..2edcf718836 100644
--- a/tests/ui/legacy_numeric_constants_unfixable.stderr
+++ b/tests/ui/legacy_numeric_constants_unfixable.stderr
@@ -1,5 +1,5 @@
error: importing legacy numeric constants
- --> tests/ui/legacy_numeric_constants_unfixable.rs:10:5
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:9:5
|
LL | use std::u128 as _;
| ^^^^^^^^^
@@ -9,7 +9,7 @@ LL | use std::u128 as _;
= help: to override `-D warnings` add `#[allow(clippy::legacy_numeric_constants)]`
error: importing legacy numeric constants
- --> tests/ui/legacy_numeric_constants_unfixable.rs:14:24
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:13:24
|
LL | pub use std::{mem, u128};
| ^^^^
@@ -18,7 +18,7 @@ LL | pub use std::{mem, u128};
= note: then `u128::` will resolve to the respective associated constant
error: importing a legacy numeric constant
- --> tests/ui/legacy_numeric_constants_unfixable.rs:30:9
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:29:9
|
LL | use std::u32::MAX;
| ^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ LL | use std::u32::MAX;
= help: remove this import and use the associated constant `u32::MAX` from the primitive type instead
error: importing a legacy numeric constant
- --> tests/ui/legacy_numeric_constants_unfixable.rs:33:9
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:32:9
|
LL | use std::u8::MIN;
| ^^^^^^^^^^^^
@@ -34,7 +34,7 @@ LL | use std::u8::MIN;
= help: remove this import and use the associated constant `u8::MIN` from the primitive type instead
error: importing legacy numeric constants
- --> tests/ui/legacy_numeric_constants_unfixable.rs:37:9
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:36:9
|
LL | use std::u32;
| ^^^^^^^^
@@ -43,7 +43,7 @@ LL | use std::u32;
= note: then `u32::` will resolve to the respective associated constant
error: importing a legacy numeric constant
- --> tests/ui/legacy_numeric_constants_unfixable.rs:41:9
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:40:9
|
LL | use std::f32::MIN_POSITIVE;
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -51,7 +51,7 @@ LL | use std::f32::MIN_POSITIVE;
= help: remove this import and use the associated constant `f32::MIN_POSITIVE` from the primitive type instead
error: importing legacy numeric constants
- --> tests/ui/legacy_numeric_constants_unfixable.rs:45:9
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:44:9
|
LL | use std::i16::*;
| ^^^^^^^^
@@ -59,7 +59,7 @@ LL | use std::i16::*;
= help: remove this import and use associated constants `i16::` from the primitive type instead
error: importing legacy numeric constants
- --> tests/ui/legacy_numeric_constants_unfixable.rs:22:17
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:21:17
|
LL | use std::u32;
| ^^^^^^^^
@@ -72,7 +72,7 @@ LL | b!();
= note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info)
error: importing a legacy numeric constant
- --> tests/ui/legacy_numeric_constants_unfixable.rs:77:9
+ --> tests/ui/legacy_numeric_constants_unfixable.rs:76:9
|
LL | use std::u32::MAX;
| ^^^^^^^^^^^^^