From 3bef3ff3d4e9b60e2d6e579c0a69f71d3e0dee57 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Fri, 14 Nov 2025 12:03:05 +0100 Subject: [PATCH] refactor(rc_buffer): remove `RcKind` not really necessary --- clippy_lints/src/types/rc_buffer.rs | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/clippy_lints/src/types/rc_buffer.rs b/clippy_lints/src/types/rc_buffer.rs index 34fd3ed2dc86..43b38bb662dc 100644 --- a/clippy_lints/src/types/rc_buffer.rs +++ b/clippy_lints/src/types/rc_buffer.rs @@ -8,15 +8,14 @@ use rustc_hir::{QPath, Ty, TyKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; use std::borrow::Cow; -use std::fmt; use super::RC_BUFFER; pub(super) fn check(cx: &LateContext<'_>, hir_ty: &Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool { let mut app = Applicability::Unspecified; - let kind = match cx.tcx.get_diagnostic_name(def_id) { - Some(sym::Rc) => RcKind::Rc, - Some(sym::Arc) => RcKind::Arc, + let rc = match cx.tcx.get_diagnostic_name(def_id) { + Some(sym::Rc) => "Rc", + Some(sym::Arc) => "Arc", _ => return false, }; if let Some(ty) = qpath_generic_tys(qpath).next() @@ -26,7 +25,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &Ty<'_>, qpath: &QPath<'_>, de cx, RC_BUFFER, hir_ty.span, - format!("usage of `{kind}` when `T` is a buffer type"), + format!("usage of `{rc}` when `T` is a buffer type"), |diag| { diag.span_suggestion_verbose(ty.span, "try", alternate, app); }, @@ -37,20 +36,6 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &Ty<'_>, qpath: &QPath<'_>, de } } -enum RcKind { - Rc, - Arc, -} - -impl fmt::Display for RcKind { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Rc => f.write_str("Rc"), - Self::Arc => f.write_str("Arc"), - } - } -} - fn match_buffer_type( cx: &LateContext<'_>, ty: &Ty<'_>,