-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #3545 - Kampfkarren:vec_boxed_sized, r=flip1995
Adds lint for Vec<Box<T: Sized>> This adds, and subsequently closes #3530. This is the first time I've ever worked with anything remotely close to internal Rust code, so I'm very much unsure about the if_chain! to figure this out! I can't get rustfmt working on WSL with nightly 2018-12-07: `error: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is unavailable for download`
- Loading branch information
Showing
6 changed files
with
97 additions
and
2 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,17 @@ | ||
struct SizedStruct { | ||
_a: i32, | ||
} | ||
|
||
struct UnsizedStruct { | ||
_a: [i32], | ||
} | ||
|
||
struct StructWithVecBox { | ||
sized_type: Vec<Box<SizedStruct>>, | ||
} | ||
|
||
struct StructWithVecBoxButItsUnsized { | ||
unsized_type: Vec<Box<UnsizedStruct>>, | ||
} | ||
|
||
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,10 @@ | ||
error: `Vec<T>` is already on the heap, the boxing is unnecessary. | ||
--> $DIR/vec_box_sized.rs:10:14 | ||
| | ||
10 | sized_type: Vec<Box<SizedStruct>>, | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` | ||
| | ||
= note: `-D clippy::vec-box` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
|