Skip to content

Commit f1c7461

Browse files
authored
refactor(rc_buffer): remove RcKind (#16089)
not really necessary Follow-up to #15803 changelog: none r? @llogiq
2 parents 540e2f4 + 3bef3ff commit f1c7461

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

clippy_lints/src/types/rc_buffer.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ use rustc_hir::{QPath, Ty, TyKind};
88
use rustc_lint::LateContext;
99
use rustc_span::symbol::sym;
1010
use std::borrow::Cow;
11-
use std::fmt;
1211

1312
use super::RC_BUFFER;
1413

1514
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
1615
let mut app = Applicability::Unspecified;
17-
let kind = match cx.tcx.get_diagnostic_name(def_id) {
18-
Some(sym::Rc) => RcKind::Rc,
19-
Some(sym::Arc) => RcKind::Arc,
16+
let rc = match cx.tcx.get_diagnostic_name(def_id) {
17+
Some(sym::Rc) => "Rc",
18+
Some(sym::Arc) => "Arc",
2019
_ => return false,
2120
};
2221
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
2625
cx,
2726
RC_BUFFER,
2827
hir_ty.span,
29-
format!("usage of `{kind}<T>` when `T` is a buffer type"),
28+
format!("usage of `{rc}<T>` when `T` is a buffer type"),
3029
|diag| {
3130
diag.span_suggestion_verbose(ty.span, "try", alternate, app);
3231
},
@@ -37,20 +36,6 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &Ty<'_>, qpath: &QPath<'_>, de
3736
}
3837
}
3938

40-
enum RcKind {
41-
Rc,
42-
Arc,
43-
}
44-
45-
impl fmt::Display for RcKind {
46-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47-
match self {
48-
Self::Rc => f.write_str("Rc"),
49-
Self::Arc => f.write_str("Arc"),
50-
}
51-
}
52-
}
53-
5439
fn match_buffer_type(
5540
cx: &LateContext<'_>,
5641
ty: &Ty<'_>,

0 commit comments

Comments
 (0)