]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/methods/bytes_nth.rs
Rm diagnostic item, use lang item
[rust.git] / clippy_lints / src / methods / bytes_nth.rs
index 76eaedea8a0d229b1d5ff32282db7eb52ddfc1f0..d512cc4eeae125acebd79058624d98ade6ab2d49 100644 (file)
@@ -1,10 +1,9 @@
 use clippy_utils::diagnostics::span_lint_and_sugg;
 use clippy_utils::source::snippet_with_applicability;
-use clippy_utils::ty::is_type_diagnostic_item;
+use clippy_utils::ty::is_type_lang_item;
 use rustc_errors::Applicability;
-use rustc_hir::Expr;
+use rustc_hir::{Expr, LangItem};
 use rustc_lint::LateContext;
-use rustc_span::sym;
 
 use super::BYTES_NTH;
 
@@ -12,7 +11,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E
     let ty = cx.typeck_results().expr_ty(recv).peel_refs();
     let caller_type = if ty.is_str() {
         "str"
-    } else if is_type_diagnostic_item(cx, ty, sym::String) {
+    } else if is_type_lang_item(cx, ty, LangItem::String) {
         "String"
     } else {
         return;
@@ -22,7 +21,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E
         cx,
         BYTES_NTH,
         expr.span,
-        &format!("called `.byte().nth()` on a `{}`", caller_type),
+        &format!("called `.bytes().nth()` on a `{caller_type}`"),
         "try",
         format!(
             "{}.as_bytes().get({})",