summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/clippy_lints/src/methods/chars_last_cmp_with_unwrap.rs
blob: c29ee0ec8c8ca5720430947f701cdc6ed6c2e7e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::methods::chars_cmp_with_unwrap;
use rustc_lint::LateContext;

use super::CHARS_LAST_CMP;

/// Checks for the `CHARS_LAST_CMP` lint with `unwrap()`.
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, info: &crate::methods::BinaryExprInfo<'_>) -> bool {
    if chars_cmp_with_unwrap::check(cx, info, &["chars", "last", "unwrap"], CHARS_LAST_CMP, "ends_with") {
        true
    } else {
        chars_cmp_with_unwrap::check(cx, info, &["chars", "next_back", "unwrap"], CHARS_LAST_CMP, "ends_with")
    }
}