Skip to content

Commit 27963c8

Browse files
committed
move chars_last_cmp_with_unwrap to its own module
1 parent 4d1f2bc commit 27963c8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use crate::methods::chars_cmp_with_unwrap;
2+
use rustc_lint::LateContext;
3+
4+
use super::CHARS_LAST_CMP;
5+
6+
/// Checks for the `CHARS_LAST_CMP` lint with `unwrap()`.
7+
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, info: &crate::methods::BinaryExprInfo<'_>) -> bool {
8+
if chars_cmp_with_unwrap::check(cx, info, &["chars", "last", "unwrap"], CHARS_LAST_CMP, "ends_with") {
9+
true
10+
} else {
11+
chars_cmp_with_unwrap::check(cx, info, &["chars", "next_back", "unwrap"], CHARS_LAST_CMP, "ends_with")
12+
}
13+
}

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod bytes_nth;
33
mod chars_cmp;
44
mod chars_cmp_with_unwrap;
55
mod chars_last_cmp;
6+
mod chars_last_cmp_with_unwrap;
67
mod chars_next_cmp;
78
mod chars_next_cmp_with_unwrap;
89
mod clone_on_copy;
@@ -1974,16 +1975,7 @@ fn lint_binary_expr_with_method_call(cx: &LateContext<'_>, info: &mut BinaryExpr
19741975
lint_with_both_lhs_and_rhs!(chars_next_cmp::check, cx, info);
19751976
lint_with_both_lhs_and_rhs!(chars_last_cmp::check, cx, info);
19761977
lint_with_both_lhs_and_rhs!(chars_next_cmp_with_unwrap::check, cx, info);
1977-
lint_with_both_lhs_and_rhs!(lint_chars_last_cmp_with_unwrap, cx, info);
1978-
}
1979-
1980-
/// Checks for the `CHARS_LAST_CMP` lint with `unwrap()`.
1981-
fn lint_chars_last_cmp_with_unwrap<'tcx>(cx: &LateContext<'tcx>, info: &BinaryExprInfo<'_>) -> bool {
1982-
if chars_cmp_with_unwrap::check(cx, info, &["chars", "last", "unwrap"], CHARS_LAST_CMP, "ends_with") {
1983-
true
1984-
} else {
1985-
chars_cmp_with_unwrap::check(cx, info, &["chars", "next_back", "unwrap"], CHARS_LAST_CMP, "ends_with")
1986-
}
1978+
lint_with_both_lhs_and_rhs!(chars_last_cmp_with_unwrap::check, cx, info);
19871979
}
19881980

19891981
fn get_hint_if_single_char_arg(

0 commit comments

Comments
 (0)