Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lyj
committed
Jun 4, 2021
1 parent
84c511f
commit c0f3c2f
Showing
7 changed files
with
127 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// run-rustfix | ||
#![warn(clippy::rc_mutex)] | ||
#![allow(unused_imports)] | ||
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)] | ||
#![allow(clippy::blacklisted_name, unused_variables, dead_code)] | ||
|
||
use std::cell::RefCell; | ||
use std::rc::Rc; | ||
use std::sync::Mutex; | ||
|
||
pub struct MyStruct {} | ||
|
||
pub struct SubT<T> { | ||
foo: T, | ||
} | ||
|
||
pub enum MyEnum { | ||
One, | ||
Two, | ||
} | ||
|
||
pub fn test1<T>(foo: Rc<RefCell<T>>) {} | ||
|
||
pub fn test2(foo: Rc<RefCell<MyEnum>>) {} | ||
|
||
pub fn test3(foo: Rc<RefCell<SubT<usize>>>) {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// run-rustfix | ||
#![warn(clippy::rc_mutex)] | ||
#![allow(unused_imports)] | ||
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)] | ||
#![allow(clippy::blacklisted_name, unused_variables, dead_code)] | ||
|
||
use std::cell::RefCell; | ||
use std::rc::Rc; | ||
use std::sync::Mutex; | ||
|
||
pub struct MyStruct {} | ||
|
||
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>>>) {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: you seem to be trying to use `Rc<Mutex<T>>`. Consider using `Rc<RefCell<T>>` | ||
--> $DIR/rc_mutex.rs:22:22 | ||
| | ||
LL | pub fn test1<T>(foo: Rc<Mutex<T>>) {} | ||
| ^^^^^^^^^^^^ help: try: `Rc<RefCell<T>>` | ||
| | ||
= note: `-D clippy::rc-mutex` implied by `-D warnings` | ||
|
||
error: you seem to be trying to use `Rc<Mutex<T>>`. Consider using `Rc<RefCell<T>>` | ||
--> $DIR/rc_mutex.rs:24:19 | ||
| | ||
LL | pub fn test2(foo: Rc<Mutex<MyEnum>>) {} | ||
| ^^^^^^^^^^^^^^^^^ help: try: `Rc<RefCell<MyEnum>>` | ||
|
||
error: you seem to be trying to use `Rc<Mutex<T>>`. Consider using `Rc<RefCell<T>>` | ||
--> $DIR/rc_mutex.rs:26:19 | ||
| | ||
LL | pub fn test3(foo: Rc<Mutex<SubT<usize>>>) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc<RefCell<SubT<usize>>>` | ||
|
||
error: aborting due to 3 previous errors | ||
|