Skip to content

Commit 849dbe8

Browse files
committed
Switched to symbols instead of using strings
1 parent 113368e commit 849dbe8

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

clippy_lints/src/methods/chunks_exact_to_as_chunks.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use clippy_utils::consts::{ConstEvalCtxt, Constant};
22
use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::msrvs::{self, Msrv};
4+
use clippy_utils::sym;
45
use rustc_hir::Expr;
56
use rustc_lint::LateContext;
7+
use rustc_span::Symbol;
68

79
use super::CHUNKS_EXACT_TO_AS_CHUNKS;
810

@@ -11,7 +13,7 @@ pub(super) fn check(
1113
expr: &Expr<'_>,
1214
recv: &Expr<'_>,
1315
arg: &Expr<'_>,
14-
method_name: &str,
16+
method_name: Symbol,
1517
msrv: Msrv,
1618
) {
1719
// Check for Rust version
@@ -29,7 +31,7 @@ pub(super) fn check(
2931
let constant_eval = ConstEvalCtxt::new(cx);
3032
if let Some(Constant::Int(chunk_size)) = constant_eval.eval(arg) {
3133
// Emit the lint
32-
let suggestion = if method_name == "chunks_exact_mut" {
34+
let suggestion = if method_name == sym::chunks_exact_mut {
3335
"as_chunks_mut"
3436
} else {
3537
"as_chunks"

clippy_lints/src/methods/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4815,6 +4815,7 @@ impl_lint_pass!(Methods => [
48154815
ITER_NTH,
48164816
ITER_NTH_ZERO,
48174817
BYTES_NTH,
4818+
CHUNKS_EXACT_TO_AS_CHUNKS,
48184819
ITER_SKIP_NEXT,
48194820
GET_UNWRAP,
48204821
GET_LAST_WITH_LEN,
@@ -5752,8 +5753,8 @@ impl Methods {
57525753
unwrap_expect_used::Variant::Unwrap,
57535754
);
57545755
},
5755-
(name, [arg]) if matches!(name.as_str(), "chunks_exact" | "chunks_exact_mut") => {
5756-
chunks_exact_to_as_chunks::check(cx, expr, recv, arg, name.as_str(), self.msrv);
5756+
(name @ (sym::chunks_exact | sym::chunks_exact_mut), [arg]) => {
5757+
chunks_exact_to_as_chunks::check(cx, expr, recv, arg, name, self.msrv);
57575758
},
57585759
_ => {},
57595760
}

clippy_utils/src/sym.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ generate! {
111111
checked_pow,
112112
checked_rem_euclid,
113113
checked_sub,
114+
chunks_exact,
115+
chunks_exact_mut,
114116
clamp,
115117
clippy_utils,
116118
clone_into,

0 commit comments

Comments
 (0)