mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
manual_range_pattern -> manual_range_patterns
This commit is contained in:
parent
1d4afc5d82
commit
b592d39968
11 changed files with 22 additions and 22 deletions
|
@ -4949,7 +4949,7 @@ Released 2018-09-13
|
|||
[`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
|
||||
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
|
||||
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
|
||||
[`manual_range_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_pattern
|
||||
[`manual_range_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_patterns
|
||||
[`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid
|
||||
[`manual_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain
|
||||
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
|
||||
|
|
|
@ -278,7 +278,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
|
|||
crate::manual_let_else::MANUAL_LET_ELSE_INFO,
|
||||
crate::manual_main_separator_str::MANUAL_MAIN_SEPARATOR_STR_INFO,
|
||||
crate::manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE_INFO,
|
||||
crate::manual_range_pattern::MANUAL_RANGE_PATTERN_INFO,
|
||||
crate::manual_range_patterns::MANUAL_RANGE_PATTERNS_INFO,
|
||||
crate::manual_rem_euclid::MANUAL_REM_EUCLID_INFO,
|
||||
crate::manual_retain::MANUAL_RETAIN_INFO,
|
||||
crate::manual_slice_size_calculation::MANUAL_SLICE_SIZE_CALCULATION_INFO,
|
||||
|
|
|
@ -188,7 +188,7 @@ mod manual_is_ascii_check;
|
|||
mod manual_let_else;
|
||||
mod manual_main_separator_str;
|
||||
mod manual_non_exhaustive;
|
||||
mod manual_range_pattern;
|
||||
mod manual_range_patterns;
|
||||
mod manual_rem_euclid;
|
||||
mod manual_retain;
|
||||
mod manual_slice_size_calculation;
|
||||
|
@ -1069,7 +1069,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||
needless_raw_string_hashes_allow_one,
|
||||
})
|
||||
});
|
||||
store.register_late_pass(|_| Box::new(manual_range_pattern::ManualRangePattern));
|
||||
store.register_late_pass(|_| Box::new(manual_range_patterns::ManualRangePatterns));
|
||||
// add lints here, do not remove this comment, it's used in `new_lint`
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ declare_clippy_lint! {
|
|||
/// let foo = matches!(x, 1..=10);
|
||||
/// ```
|
||||
#[clippy::version = "1.72.0"]
|
||||
pub MANUAL_RANGE_PATTERN,
|
||||
pub MANUAL_RANGE_PATTERNS,
|
||||
complexity,
|
||||
"manually writing range patterns using a combined OR pattern (`|`)"
|
||||
}
|
||||
declare_lint_pass!(ManualRangePattern => [MANUAL_RANGE_PATTERN]);
|
||||
declare_lint_pass!(ManualRangePatterns => [MANUAL_RANGE_PATTERNS]);
|
||||
|
||||
fn expr_as_u128(expr: &Expr<'_>) -> Option<u128> {
|
||||
if let ExprKind::Lit(lit) = expr.kind
|
||||
|
@ -46,7 +46,7 @@ fn expr_as_u128(expr: &Expr<'_>) -> Option<u128> {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass<'_> for ManualRangePattern {
|
||||
impl LateLintPass<'_> for ManualRangePatterns {
|
||||
fn check_pat(&mut self, cx: &LateContext<'_>, pat: &'_ rustc_hir::Pat<'_>) {
|
||||
if in_external_macro(cx.sess(), pat.span) {
|
||||
return;
|
||||
|
@ -110,7 +110,7 @@ impl LateLintPass<'_> for ManualRangePattern {
|
|||
if contains_whole_range {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
MANUAL_RANGE_PATTERN,
|
||||
MANUAL_RANGE_PATTERNS,
|
||||
pat.span,
|
||||
"this OR pattern can be rewritten using a range",
|
||||
"try",
|
|
@ -1,7 +1,7 @@
|
|||
//@run-rustfix
|
||||
|
||||
#![allow(unused)]
|
||||
#![warn(clippy::manual_range_pattern)]
|
||||
#![warn(clippy::manual_range_patterns)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
|
||||
fn main() {
|
|
@ -1,7 +1,7 @@
|
|||
//@run-rustfix
|
||||
|
||||
#![allow(unused)]
|
||||
#![warn(clippy::manual_range_pattern)]
|
||||
#![warn(clippy::manual_range_patterns)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
|
||||
fn main() {
|
|
@ -1,43 +1,43 @@
|
|||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:10:25
|
||||
--> $DIR/manual_range_patterns.rs:10:25
|
||||
|
|
||||
LL | let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
|
||||
= note: `-D clippy::manual-range-pattern` implied by `-D warnings`
|
||||
= note: `-D clippy::manual-range-patterns` implied by `-D warnings`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:11:25
|
||||
--> $DIR/manual_range_patterns.rs:11:25
|
||||
|
|
||||
LL | let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 7 | 8 | 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:20:25
|
||||
--> $DIR/manual_range_patterns.rs:20:25
|
||||
|
|
||||
LL | let _ = matches!(f, (1..=10) | (2..=13) | (14..=48324728) | 48324729);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=48324729`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:21:25
|
||||
--> $DIR/manual_range_patterns.rs:21:25
|
||||
|
|
||||
LL | let _ = matches!(f, 0 | (1..=10) | 48324730 | (2..=13) | (14..=48324728) | 48324729);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0..=48324730`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:22:25
|
||||
--> $DIR/manual_range_patterns.rs:22:25
|
||||
|
|
||||
LL | let _ = matches!(f, 0..=1 | 0..=2 | 0..=3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `0..=3`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:25:9
|
||||
--> $DIR/manual_range_patterns.rs:25:9
|
||||
|
|
||||
LL | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => true,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_pattern.rs:31:26
|
||||
--> $DIR/manual_range_patterns.rs:31:26
|
||||
|
|
||||
LL | matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
|
@ -7,7 +7,7 @@
|
|||
clippy::match_ref_pats,
|
||||
clippy::upper_case_acronyms,
|
||||
clippy::needless_if,
|
||||
clippy::manual_range_pattern
|
||||
clippy::manual_range_patterns
|
||||
)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused)]
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
clippy::match_ref_pats,
|
||||
clippy::upper_case_acronyms,
|
||||
clippy::needless_if,
|
||||
clippy::manual_range_pattern
|
||||
clippy::manual_range_patterns
|
||||
)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused)]
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
clippy::cognitive_complexity,
|
||||
clippy::match_ref_pats,
|
||||
clippy::needless_if,
|
||||
clippy::manual_range_pattern
|
||||
clippy::manual_range_patterns
|
||||
)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
clippy::cognitive_complexity,
|
||||
clippy::match_ref_pats,
|
||||
clippy::needless_if,
|
||||
clippy::manual_range_pattern
|
||||
clippy::manual_range_patterns
|
||||
)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
|
||||
|
||||
|
|
Loading…
Reference in a new issue