diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index 07dec2de8279..30b04e4174ca 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -254,22 +254,10 @@ declare_clippy_lint! { declare_clippy_lint! { /// **What it does:** Checks for `Rc>`. /// - /// **Why is this bad?** `Rc>` may introduce a deadlock in single thread. Consider - /// using `Rc>` instead. - /// ```rust - /// fn main() { - /// use std::rc::Rc; - /// use std::sync::Mutex; + /// **Why is this bad?** `Rc` is used in single thread and `Mutex` is used in multi thread. + /// Consider using `Rc>` in single thread or `Arc>` in multi thread. /// - /// let a: Rc> = Rc::new(Mutex::new(1)); - /// let a_clone = a.clone(); - /// let mut data = a.lock().unwrap(); - /// println!("{:?}", *a_clone.lock().unwrap()); - /// *data = 10; - /// } - /// ``` - /// - /// **Known problems:** `Rc>` may panic in runtime. + /// **Known problems:** None. /// /// **Example:** /// ```rust,ignore diff --git a/clippy_lints/src/types/rc_mutex.rs b/clippy_lints/src/types/rc_mutex.rs index e8109f123245..bd7a0ee6408f 100644 --- a/clippy_lints/src/types/rc_mutex.rs +++ b/clippy_lints/src/types/rc_mutex.rs @@ -17,7 +17,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ cx, RC_MUTEX, hir_ty.span, - "found `Rc>`. Consider using `Rc>` instead", + "found `Rc>`. Consider using `Rc>` or `Arc>` instead", ); return true; } diff --git a/tests/ui/rc_mutex.stderr b/tests/ui/rc_mutex.stderr index ab59337a9609..c32780acf9f2 100644 --- a/tests/ui/rc_mutex.stderr +++ b/tests/ui/rc_mutex.stderr @@ -1,4 +1,4 @@ -error: found `Rc>`. Consider using `Rc>` instead +error: found `Rc>`. Consider using `Rc>` or `Arc>` instead --> $DIR/rc_mutex.rs:9:10 | LL | foo: Rc>, @@ -6,19 +6,19 @@ LL | foo: Rc>, | = note: `-D clippy::rc-mutex` implied by `-D warnings` -error: found `Rc>`. Consider using `Rc>` instead +error: found `Rc>`. Consider using `Rc>` or `Arc>` instead --> $DIR/rc_mutex.rs:21:22 | LL | pub fn test1(foo: Rc>) {} | ^^^^^^^^^^^^ -error: found `Rc>`. Consider using `Rc>` instead +error: found `Rc>`. Consider using `Rc>` or `Arc>` instead --> $DIR/rc_mutex.rs:23:19 | LL | pub fn test2(foo: Rc>) {} | ^^^^^^^^^^^^^^^^^ -error: found `Rc>`. Consider using `Rc>` instead +error: found `Rc>`. Consider using `Rc>` or `Arc>` instead --> $DIR/rc_mutex.rs:25:19 | LL | pub fn test3(foo: Rc>>) {}