mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Updated lint message for rc_mutex
This commit is contained in:
parent
7bfc26ec8e
commit
09b7745f34
2 changed files with 17 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue