-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>
- Loading branch information
1 parent
cd6eafd
commit 063de76
Showing
12 changed files
with
283 additions
and
25 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
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,30 @@ | ||
#![warn(clippy::all)] | ||
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)] | ||
#![allow(clippy::blacklisted_name)] | ||
|
||
use std::rc::Rc; | ||
|
||
pub struct MyStruct {} | ||
|
||
pub struct SubT<T> { | ||
foo: T, | ||
} | ||
|
||
pub enum MyEnum { | ||
One, | ||
Two, | ||
} | ||
|
||
pub fn test<T>(foo: Rc<&T>) {} | ||
|
||
pub fn test1(foo: Rc<&usize>) {} | ||
|
||
pub fn test2(foo: Rc<&MyStruct>) {} | ||
|
||
pub fn test3(foo: Rc<&MyEnum>) {} | ||
|
||
pub fn test4(foo: Rc<&&MyEnum>) {} | ||
|
||
pub fn test6(foo: Rc<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,43 @@ | ||
error: usage of `Rc<&T>` | ||
--> $DIR/rc_borrows.rs:18:21 | ||
| | ||
LL | pub fn test<T>(foo: Rc<&T>) {} | ||
| ^^^^^^ | ||
| | ||
= note: `-D clippy::rc-borrows` implied by `-D warnings` | ||
= help: try `&T` | ||
|
||
error: usage of `Rc<&T>` | ||
--> $DIR/rc_borrows.rs:20:19 | ||
| | ||
LL | pub fn test1(foo: Rc<&usize>) {} | ||
| ^^^^^^^^^^ | ||
| | ||
= help: try `&usize` | ||
|
||
error: usage of `Rc<&T>` | ||
--> $DIR/rc_borrows.rs:22:19 | ||
| | ||
LL | pub fn test2(foo: Rc<&MyStruct>) {} | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= help: try `&MyStruct` | ||
|
||
error: usage of `Rc<&T>` | ||
--> $DIR/rc_borrows.rs:24:19 | ||
| | ||
LL | pub fn test3(foo: Rc<&MyEnum>) {} | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: try `&MyEnum` | ||
|
||
error: usage of `Rc<&T>` | ||
--> $DIR/rc_borrows.rs:26:19 | ||
| | ||
LL | pub fn test4(foo: Rc<&&MyEnum>) {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: try `&&MyEnum` | ||
|
||
error: aborting due to 5 previous errors | ||
|
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,8 @@ | ||
use std::boxed::Box; | ||
use std::rc::Rc; | ||
|
||
pub fn test(a: Rc<Rc<bool>>) {} | ||
|
||
pub fn test2(a: Rc<Box<bool>>) {} | ||
|
||
fn main() {} |
Oops, something went wrong.