1 use crate::utils::{is_type_diagnostic_item, method_chain_args, snippet_with_applicability, span_lint_and_sugg};
2 use rustc_errors::Applicability;
4 use rustc_lint::LateContext;
6 use rustc_span::symbol::sym;
8 use super::STRING_EXTEND_CHARS;
10 pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) {
11 let obj_ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
12 if is_type_diagnostic_item(cx, obj_ty, sym::string_type) {
14 if let Some(arglists) = method_chain_args(arg, &["chars"]) {
15 let target = &arglists[0][0];
16 let self_ty = cx.typeck_results().expr_ty(target).peel_refs();
17 let ref_str = if *self_ty.kind() == ty::Str {
19 } else if is_type_diagnostic_item(cx, self_ty, sym::string_type) {
25 let mut applicability = Applicability::MachineApplicable;
30 "calling `.extend(_.chars())`",
34 snippet_with_applicability(cx, args[0].span, "..", &mut applicability),
36 snippet_with_applicability(cx, target.span, "..", &mut applicability)