refactor string_extend_chars: return when obj type is not string
This commit is contained in:
parent
058d8c878a
commit
c07c046b31
@ -12,7 +12,9 @@ use super::STRING_EXTEND_CHARS;
|
|||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) {
|
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) {
|
||||||
let obj_ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
|
let obj_ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
|
||||||
if is_type_diagnostic_item(cx, obj_ty, sym::string_type) {
|
if !is_type_diagnostic_item(cx, obj_ty, sym::string_type) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let arg = &args[1];
|
let arg = &args[1];
|
||||||
if let Some(arglists) = method_chain_args(arg, &["chars"]) {
|
if let Some(arglists) = method_chain_args(arg, &["chars"]) {
|
||||||
let target = &arglists[0][0];
|
let target = &arglists[0][0];
|
||||||
@ -42,4 +44,3 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Exp
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user