diff options
| -rw-r--r-- | clippy_lints/src/types/rc_mutex.rs | 11 | ||||
| -rw-r--r-- | tests/ui/rc_mutex.stderr | 15 |
2 files changed, 17 insertions, 9 deletions
diff --git a/clippy_lints/src/types/rc_mutex.rs b/clippy_lints/src/types/rc_mutex.rs index bd7a0ee6408..12db7afb81c 100644 --- a/clippy_lints/src/types/rc_mutex.rs +++ b/clippy_lints/src/types/rc_mutex.rs @@ -1,4 +1,4 @@ -use clippy_utils::diagnostics::span_lint; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::is_ty_param_diagnostic_item; use if_chain::if_chain; use rustc_hir::{self as hir, def_id::DefId, QPath}; @@ -11,13 +11,14 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ if_chain! { if cx.tcx.is_diagnostic_item(sym::Rc, def_id) ; if let Some(_) = is_ty_param_diagnostic_item(cx, qpath, sym!(mutex_type)) ; - - then{ - span_lint( + then { + span_lint_and_help( cx, RC_MUTEX, hir_ty.span, - "found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead", + "usage of `Rc<Mutex<_>>`", + None, + "consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead", ); return true; } diff --git a/tests/ui/rc_mutex.stderr b/tests/ui/rc_mutex.stderr index 8e58e2bc2d0..852e415cf1e 100644 --- a/tests/ui/rc_mutex.stderr +++ b/tests/ui/rc_mutex.stderr @@ -1,28 +1,35 @@ -error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead +error: usage of `Rc<Mutex<_>>` --> $DIR/rc_mutex.rs:8:10 | LL | foo: Rc<Mutex<i32>>, | ^^^^^^^^^^^^^^ | = note: `-D clippy::rc-mutex` implied by `-D warnings` + = help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead -error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead +error: usage of `Rc<Mutex<_>>` --> $DIR/rc_mutex.rs:20:22 | LL | pub fn test1<T>(foo: Rc<Mutex<T>>) {} | ^^^^^^^^^^^^ + | + = help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead -error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead +error: usage of `Rc<Mutex<_>>` --> $DIR/rc_mutex.rs:22:19 | LL | pub fn test2(foo: Rc<Mutex<MyEnum>>) {} | ^^^^^^^^^^^^^^^^^ + | + = help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead -error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead +error: usage of `Rc<Mutex<_>>` --> $DIR/rc_mutex.rs:24:19 | LL | pub fn test3(foo: Rc<Mutex<SubT<usize>>>) {} | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead error: aborting due to 4 previous errors |
