forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint for Vec<Box<T: Sized>> - Closes rust-lang#3530
- Loading branch information
1 parent
379c934
commit ab07050
Showing
4 changed files
with
93 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
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,11 @@ | ||
error: you seem to be trying to use `Vec<Box<T>>`, but T is Sized. Consider using just `Vec<T>` | ||
--> $DIR/vec_box_sized.rs:10:14 | ||
| | ||
10 | sized_type: Vec<Box<SizedStruct>>, | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::vec-box-sized` implied by `-D warnings` | ||
= help: `Vec<T>` is already on the heap, `Vec<Box<T>>` makes an extra allocation. | ||
|
||
error: aborting due to previous error | ||
|