Skip to content

Commit 09b7745

Browse files
committed
Updated lint message for rc_mutex
1 parent 7bfc26e commit 09b7745

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

clippy_lints/src/types/rc_mutex.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clippy_utils::diagnostics::span_lint;
1+
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::is_ty_param_diagnostic_item;
33
use if_chain::if_chain;
44
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<'_
1111
if_chain! {
1212
if cx.tcx.is_diagnostic_item(sym::Rc, def_id) ;
1313
if let Some(_) = is_ty_param_diagnostic_item(cx, qpath, sym!(mutex_type)) ;
14-
15-
then{
16-
span_lint(
14+
then {
15+
span_lint_and_help(
1716
cx,
1817
RC_MUTEX,
1918
hir_ty.span,
20-
"found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead",
19+
"usage of `Rc<Mutex<_>>`",
20+
None,
21+
"consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead",
2122
);
2223
return true;
2324
}

tests/ui/rc_mutex.stderr

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
1+
error: usage of `Rc<Mutex<_>>`
22
--> $DIR/rc_mutex.rs:8:10
33
|
44
LL | foo: Rc<Mutex<i32>>,
55
| ^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::rc-mutex` implied by `-D warnings`
8+
= help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
89

9-
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
10+
error: usage of `Rc<Mutex<_>>`
1011
--> $DIR/rc_mutex.rs:20:22
1112
|
1213
LL | pub fn test1<T>(foo: Rc<Mutex<T>>) {}
1314
| ^^^^^^^^^^^^
15+
|
16+
= help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
1417

15-
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
18+
error: usage of `Rc<Mutex<_>>`
1619
--> $DIR/rc_mutex.rs:22:19
1720
|
1821
LL | pub fn test2(foo: Rc<Mutex<MyEnum>>) {}
1922
| ^^^^^^^^^^^^^^^^^
23+
|
24+
= help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
2025

21-
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
26+
error: usage of `Rc<Mutex<_>>`
2227
--> $DIR/rc_mutex.rs:24:19
2328
|
2429
LL | pub fn test3(foo: Rc<Mutex<SubT<usize>>>) {}
2530
| ^^^^^^^^^^^^^^^^^^^^^^
31+
|
32+
= help: consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
2633

2734
error: aborting due to 4 previous errors
2835

0 commit comments

Comments
 (0)