]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/types/rc_buffer.rs
Add flags to detect lints are triggered
[rust.git] / clippy_lints / src / types / rc_buffer.rs
index 11e25c8bdcb0d11c08b564c7408a46fe12c5d88c..e34b95147e10a6d4cf2fb2c06734b9d1459a71d2 100644 (file)
@@ -9,7 +9,7 @@
 
 use super::RC_BUFFER;
 
-pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) {
+pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
     if cx.tcx.is_diagnostic_item(sym::Rc, def_id) {
         if let Some(alternate) = match_buffer_type(cx, qpath) {
             span_lint_and_sugg(
@@ -24,11 +24,11 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
         } else if let Some(ty) = is_ty_param_diagnostic_item(cx, qpath, sym::vec_type) {
             let qpath = match &ty.kind {
                 TyKind::Path(qpath) => qpath,
-                _ => return,
+                _ => return false,
             };
             let inner_span = match get_qpath_generic_tys(qpath).next() {
                 Some(ty) => ty.span,
-                None => return,
+                None => return false,
             };
             let mut applicability = Applicability::MachineApplicable;
             span_lint_and_sugg(
@@ -43,6 +43,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
                 ),
                 Applicability::MachineApplicable,
             );
+            return true;
         }
     } else if cx.tcx.is_diagnostic_item(sym::Arc, def_id) {
         if let Some(alternate) = match_buffer_type(cx, qpath) {
@@ -58,11 +59,11 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
         } else if let Some(ty) = is_ty_param_diagnostic_item(cx, qpath, sym::vec_type) {
             let qpath = match &ty.kind {
                 TyKind::Path(qpath) => qpath,
-                _ => return,
+                _ => return false,
             };
             let inner_span = match get_qpath_generic_tys(qpath).next() {
                 Some(ty) => ty.span,
-                None => return,
+                None => return false,
             };
             let mut applicability = Applicability::MachineApplicable;
             span_lint_and_sugg(
@@ -77,8 +78,11 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
                 ),
                 Applicability::MachineApplicable,
             );
+            return true;
         }
     }
+
+    false
 }
 
 fn match_buffer_type(cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<&'static str> {