-
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.
- Loading branch information
1 parent
100a24d
commit cd6eafd
Showing
6 changed files
with
138 additions
and
1 deletion.
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,30 @@ | ||
#![warn(clippy::all)] | ||
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)] | ||
#![allow(clippy::blacklisted_name)] | ||
|
||
pub struct MyStruct {} | ||
|
||
pub struct SubT<T> { | ||
foo: T, | ||
} | ||
|
||
pub enum MyEnum { | ||
One, | ||
Two, | ||
} | ||
|
||
pub fn test<T>(foo: Box<&T>) {} | ||
|
||
pub fn test1(foo: Box<&usize>) {} | ||
|
||
pub fn test2(foo: Box<&MyStruct>) {} | ||
|
||
pub fn test3(foo: Box<&MyEnum>) {} | ||
|
||
pub fn test4(foo: Box<&&MyEnum>) {} | ||
|
||
pub fn test5(foo: Box<Box<&usize>>) {} | ||
|
||
pub fn test6(foo: Box<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,51 @@ | ||
error: usage of `Box<&T>` | ||
--> $DIR/box_borrows.rs:16:21 | ||
| | ||
LL | pub fn test<T>(foo: Box<&T>) {} | ||
| ^^^^^^^ | ||
| | ||
= note: `-D clippy::box-borrows` implied by `-D warnings` | ||
= help: try `&T` | ||
|
||
error: usage of `Box<&T>` | ||
--> $DIR/box_borrows.rs:18:19 | ||
| | ||
LL | pub fn test1(foo: Box<&usize>) {} | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: try `&usize` | ||
|
||
error: usage of `Box<&T>` | ||
--> $DIR/box_borrows.rs:20:19 | ||
| | ||
LL | pub fn test2(foo: Box<&MyStruct>) {} | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: try `&MyStruct` | ||
|
||
error: usage of `Box<&T>` | ||
--> $DIR/box_borrows.rs:22:19 | ||
| | ||
LL | pub fn test3(foo: Box<&MyEnum>) {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: try `&MyEnum` | ||
|
||
error: usage of `Box<&T>` | ||
--> $DIR/box_borrows.rs:24:19 | ||
| | ||
LL | pub fn test4(foo: Box<&&MyEnum>) {} | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= help: try `&&MyEnum` | ||
|
||
error: usage of `Box<&T>` | ||
--> $DIR/box_borrows.rs:26:23 | ||
| | ||
LL | pub fn test5(foo: Box<Box<&usize>>) {} | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: try `&usize` | ||
|
||
error: aborting due to 6 previous errors | ||
|