@@ -8,15 +8,14 @@ use rustc_hir::{QPath, Ty, TyKind};
88use rustc_lint:: LateContext ;
99use rustc_span:: symbol:: sym;
1010use std:: borrow:: Cow ;
11- use std:: fmt;
1211
1312use super :: RC_BUFFER ;
1413
1514pub ( 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-
5439fn match_buffer_type (
5540 cx : & LateContext < ' _ > ,
5641 ty : & Ty < ' _ > ,
0 commit comments