rust-clippy/tests/ui/rc_mutex.rs

35 lines
575 B
Rust
Raw Normal View History

2021-06-03 06:56:34 +00:00
#![warn(clippy::rc_mutex)]
2021-06-05 14:42:48 +00:00
#![allow(clippy::blacklisted_name)]
2021-06-03 06:56:34 +00:00
use std::rc::Rc;
use std::sync::Mutex;
2021-06-05 13:20:02 +00:00
pub struct MyStruct {
foo: Rc<Mutex<i32>>,
}
2021-06-03 06:56:34 +00:00
pub struct SubT<T> {
foo: T,
}
pub enum MyEnum {
One,
Two,
}
pub fn test1<T>(foo: Rc<Mutex<T>>) {}
pub fn test2(foo: Rc<Mutex<MyEnum>>) {}
pub fn test3(foo: Rc<Mutex<SubT<usize>>>) {}
2021-06-05 14:42:48 +00:00
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)),
};
}