summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/clippy_lints/src/types/rc_buffer.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/clippy_lints/src/types/rc_buffer.rs27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/tools/clippy/clippy_lints/src/types/rc_buffer.rs b/src/tools/clippy/clippy_lints/src/types/rc_buffer.rs
index 4d72a29e8..fa567b9b2 100644
--- a/src/tools/clippy/clippy_lints/src/types/rc_buffer.rs
+++ b/src/tools/clippy/clippy_lints/src/types/rc_buffer.rs
@@ -9,6 +9,7 @@ use rustc_span::symbol::sym;
use super::RC_BUFFER;
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
+ let app = Applicability::Unspecified;
if cx.tcx.is_diagnostic_item(sym::Rc, def_id) {
if let Some(alternate) = match_buffer_type(cx, qpath) {
span_lint_and_sugg(
@@ -17,8 +18,8 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
hir_ty.span,
"usage of `Rc<T>` when T is a buffer type",
"try",
- format!("Rc<{}>", alternate),
- Applicability::MachineApplicable,
+ format!("Rc<{alternate}>"),
+ app,
);
} else {
let Some(ty) = qpath_generic_tys(qpath).next() else { return false };
@@ -26,15 +27,12 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
if !cx.tcx.is_diagnostic_item(sym::Vec, id) {
return false;
}
- let qpath = match &ty.kind {
- TyKind::Path(qpath) => qpath,
- _ => return false,
- };
+ let TyKind::Path(qpath) = &ty.kind else { return false };
let inner_span = match qpath_generic_tys(qpath).next() {
Some(ty) => ty.span,
None => return false,
};
- let mut applicability = Applicability::MachineApplicable;
+ let mut applicability = app;
span_lint_and_sugg(
cx,
RC_BUFFER,
@@ -45,7 +43,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
"Rc<[{}]>",
snippet_with_applicability(cx, inner_span, "..", &mut applicability)
),
- Applicability::MachineApplicable,
+ app,
);
return true;
}
@@ -57,23 +55,20 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
hir_ty.span,
"usage of `Arc<T>` when T is a buffer type",
"try",
- format!("Arc<{}>", alternate),
- Applicability::MachineApplicable,
+ format!("Arc<{alternate}>"),
+ app,
);
} else if let Some(ty) = qpath_generic_tys(qpath).next() {
let Some(id) = path_def_id(cx, ty) else { return false };
if !cx.tcx.is_diagnostic_item(sym::Vec, id) {
return false;
}
- let qpath = match &ty.kind {
- TyKind::Path(qpath) => qpath,
- _ => return false,
- };
+ let TyKind::Path(qpath) = &ty.kind else { return false };
let inner_span = match qpath_generic_tys(qpath).next() {
Some(ty) => ty.span,
None => return false,
};
- let mut applicability = Applicability::MachineApplicable;
+ let mut applicability = app;
span_lint_and_sugg(
cx,
RC_BUFFER,
@@ -84,7 +79,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
"Arc<[{}]>",
snippet_with_applicability(cx, inner_span, "..", &mut applicability)
),
- Applicability::MachineApplicable,
+ app,
);
return true;
}