From 77265930a592fb65d9c0fd890c0b9a9daf7024cb Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Tue, 17 Sep 2024 16:22:16 +0100 Subject: [PATCH] Use path_res instead of lowering hir::Ty to ty::Ty --- clippy_lints/src/unnecessary_literal_bound.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/unnecessary_literal_bound.rs b/clippy_lints/src/unnecessary_literal_bound.rs index 4fa23664b8c9..f18128ac17db 100644 --- a/clippy_lints/src/unnecessary_literal_bound.rs +++ b/clippy_lints/src/unnecessary_literal_bound.rs @@ -1,8 +1,10 @@ use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::path_res; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; +use rustc_hir::def::Res; use rustc_hir::intravisit::{FnKind, Visitor}; -use rustc_hir::{Body, Expr, ExprKind, FnDecl, FnRetTy, Lit, MutTy, Mutability, Ty, TyKind, intravisit}; +use rustc_hir::{Body, Expr, ExprKind, FnDecl, FnRetTy, Lit, MutTy, Mutability, PrimTy, Ty, TyKind, intravisit}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::Span; @@ -140,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryLiteralBound { return; }; - if !rustc_hir_analysis::lower_ty(cx.tcx, inner_hir_ty).is_str() { + if path_res(cx, inner_hir_ty) != Res::PrimTy(PrimTy::Str) { return; }