Skip to content

Commit 19e7448

Browse files
committed
move PATTERN_METHODS table directly into file
also removed rustfmt::skip
1 parent c080899 commit 19e7448

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,29 +2189,6 @@ const TRAIT_METHODS: [ShouldImplTraitCase; 30] = [
21892189
ShouldImplTraitCase::new("std::ops::Sub", "sub", 2, FN_HEADER, SelfKind::Value, OutType::Any, true),
21902190
];
21912191

2192-
#[rustfmt::skip]
2193-
const PATTERN_METHODS: [(&str, usize); 19] = [
2194-
("contains", 1),
2195-
("starts_with", 1),
2196-
("ends_with", 1),
2197-
("find", 1),
2198-
("rfind", 1),
2199-
("split", 1),
2200-
("rsplit", 1),
2201-
("split_terminator", 1),
2202-
("rsplit_terminator", 1),
2203-
("splitn", 2),
2204-
("rsplitn", 2),
2205-
("matches", 1),
2206-
("rmatches", 1),
2207-
("match_indices", 1),
2208-
("rmatch_indices", 1),
2209-
("strip_prefix", 1),
2210-
("strip_suffix", 1),
2211-
("trim_start_matches", 1),
2212-
("trim_end_matches", 1),
2213-
];
2214-
22152192
#[derive(Clone, Copy, PartialEq, Debug)]
22162193
enum SelfKind {
22172194
Value,

clippy_lints/src/methods/single_char_pattern.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,31 @@ use rustc_span::symbol::Symbol;
99

1010
use super::SINGLE_CHAR_PATTERN;
1111

12+
const PATTERN_METHODS: [(&str, usize); 19] = [
13+
("contains", 1),
14+
("starts_with", 1),
15+
("ends_with", 1),
16+
("find", 1),
17+
("rfind", 1),
18+
("split", 1),
19+
("rsplit", 1),
20+
("split_terminator", 1),
21+
("rsplit_terminator", 1),
22+
("splitn", 2),
23+
("rsplitn", 2),
24+
("matches", 1),
25+
("rmatches", 1),
26+
("match_indices", 1),
27+
("rmatch_indices", 1),
28+
("strip_prefix", 1),
29+
("strip_suffix", 1),
30+
("trim_start_matches", 1),
31+
("trim_end_matches", 1),
32+
];
33+
1234
/// lint for length-1 `str`s for methods in `PATTERN_METHODS`
1335
pub(super) fn check(cx: &LateContext<'_>, _expr: &hir::Expr<'_>, method_name: Symbol, args: &[hir::Expr<'_>]) {
14-
for &(method, pos) in &crate::methods::PATTERN_METHODS {
36+
for &(method, pos) in &PATTERN_METHODS {
1537
if_chain! {
1638
if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty_adjusted(&args[0]).kind();
1739
if *ty.kind() == ty::Str;

0 commit comments

Comments
 (0)