rc_mutex: fix test

This commit is contained in:
lyj 2021-06-05 22:42:48 +08:00
parent 896c19e2cf
commit f877f54767
2 changed files with 14 additions and 7 deletions

View file

@ -1,6 +1,5 @@
#![warn(clippy::rc_mutex)]
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)]
#![allow(clippy::blacklisted_name, unused_variables, dead_code)]
#![allow(clippy::blacklisted_name)]
use std::rc::Rc;
use std::sync::Mutex;
@ -24,4 +23,12 @@ pub fn test2(foo: Rc<Mutex<MyEnum>>) {}
pub fn test3(foo: Rc<Mutex<SubT<usize>>>) {}
fn main() {}
fn main() {
test1(Rc::new(Mutex::new(1)));
test2(Rc::new(Mutex::new(MyEnum::One)));
test3(Rc::new(Mutex::new(SubT { foo: 1 })));
let _my_struct = MyStruct {
foo: Rc::new(Mutex::new(1)),
};
}

View file

@ -1,5 +1,5 @@
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
--> $DIR/rc_mutex.rs:9:10
--> $DIR/rc_mutex.rs:8:10
|
LL | foo: Rc<Mutex<i32>>,
| ^^^^^^^^^^^^^^
@ -7,19 +7,19 @@ LL | foo: Rc<Mutex<i32>>,
= note: `-D clippy::rc-mutex` implied by `-D warnings`
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
--> $DIR/rc_mutex.rs:21:22
--> $DIR/rc_mutex.rs:20:22
|
LL | pub fn test1<T>(foo: Rc<Mutex<T>>) {}
| ^^^^^^^^^^^^
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
--> $DIR/rc_mutex.rs:23:19
--> $DIR/rc_mutex.rs:22:19
|
LL | pub fn test2(foo: Rc<Mutex<MyEnum>>) {}
| ^^^^^^^^^^^^^^^^^
error: found `Rc<Mutex<_>>`. Consider using `Rc<RefCell<_>>` or `Arc<Mutex<_>>` instead
--> $DIR/rc_mutex.rs:25:19
--> $DIR/rc_mutex.rs:24:19
|
LL | pub fn test3(foo: Rc<Mutex<SubT<usize>>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^