1 use clippy_utils::diagnostics::span_lint_and_sugg;
2 use clippy_utils::method_chain_args;
3 use clippy_utils::source::snippet_with_applicability;
4 use if_chain::if_chain;
6 use rustc_errors::Applicability;
8 use rustc_lint::LateContext;
11 /// Wrapper fn for `CHARS_NEXT_CMP` and `CHARS_LAST_CMP` lints with `unwrap()`.
12 pub(super) fn check<'tcx>(
13 cx: &LateContext<'tcx>,
14 info: &crate::methods::BinaryExprInfo<'_>,
15 chain_methods: &[&str],
20 if let Some(args) = method_chain_args(info.chain, chain_methods);
21 if let hir::ExprKind::Lit(ref lit) = info.other.kind;
22 if let ast::LitKind::Char(c) = lit.node;
24 let mut applicability = Applicability::MachineApplicable;
29 &format!("you should use the `{}` method", suggest),
31 format!("{}{}.{}('{}')",
32 if info.eq { "" } else { "!" },
33 snippet_with_applicability(cx, args[0][0].span, "..", &mut applicability),