From b62d2624acec2017e9ba04bcc8e250e491f51c05 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 8d9443b71efc..80ce67111261 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; @@ -136,7 +138,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; }