string_slice should detect on Cow

This commit is contained in:
Alexey Semenyuk 2024-08-18 17:50:29 +05:00
parent 5da97d006e
commit 7b7cf440cb
3 changed files with 16 additions and 5 deletions

View file

@ -190,7 +190,7 @@ impl<'tcx> LateLintPass<'tcx> for StringAdd {
}
},
ExprKind::Index(target, _idx, _) => {
let e_ty = cx.typeck_results().expr_ty(target).peel_refs();
let e_ty = cx.typeck_results().expr_ty_adjusted(target).peel_refs();
if e_ty.is_str() || is_type_lang_item(cx, e_ty, LangItem::String) {
span_lint(
cx,