Remove references to sized for end users

This commit is contained in:
Kampfkarren
2018-12-13 10:15:56 -08:00
parent 9fc914cf4d
commit db00c3320f
4 changed files with 12 additions and 11 deletions

View File

@@ -899,7 +899,7 @@ All notable changes to this project will be documented in this file.
[`useless_let_if_seq`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_let_if_seq [`useless_let_if_seq`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_let_if_seq
[`useless_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_transmute [`useless_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_transmute
[`useless_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec [`useless_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec
[`vec_box_sized`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_box_sized [`vec_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_box
[`verbose_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask [`verbose_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask
[`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition [`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
[`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop [`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop

View File

@@ -766,7 +766,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
types::UNIT_ARG, types::UNIT_ARG,
types::UNIT_CMP, types::UNIT_CMP,
types::UNNECESSARY_CAST, types::UNNECESSARY_CAST,
types::VEC_BOX_SIZED, types::VEC_BOX,
unicode::ZERO_WIDTH_SPACE, unicode::ZERO_WIDTH_SPACE,
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME, unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
unused_io_amount::UNUSED_IO_AMOUNT, unused_io_amount::UNUSED_IO_AMOUNT,
@@ -932,7 +932,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
types::TYPE_COMPLEXITY, types::TYPE_COMPLEXITY,
types::UNIT_ARG, types::UNIT_ARG,
types::UNNECESSARY_CAST, types::UNNECESSARY_CAST,
types::VEC_BOX_SIZED, types::VEC_BOX,
unused_label::UNUSED_LABEL, unused_label::UNUSED_LABEL,
zero_div_zero::ZERO_DIVIDED_BY_ZERO, zero_div_zero::ZERO_DIVIDED_BY_ZERO,
]); ]);

View File

@@ -90,7 +90,7 @@ declare_clippy_lint! {
/// } /// }
/// ``` /// ```
declare_clippy_lint! { declare_clippy_lint! {
pub VEC_BOX_SIZED, pub VEC_BOX,
complexity, complexity,
"usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap" "usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap"
} }
@@ -175,7 +175,7 @@ declare_clippy_lint! {
impl LintPass for TypePass { impl LintPass for TypePass {
fn get_lints(&self) -> LintArray { fn get_lints(&self) -> LintArray {
lint_array!(BOX_VEC, VEC_BOX_SIZED, OPTION_OPTION, LINKEDLIST, BORROWED_BOX) lint_array!(BOX_VEC, VEC_BOX, OPTION_OPTION, LINKEDLIST, BORROWED_BOX)
} }
} }
@@ -292,13 +292,14 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
then { then {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
VEC_BOX_SIZED, VEC_BOX,
ast_ty.span, ast_ty.span,
"you seem to be trying to use `Vec<Box<T>>`, but T is Sized. `Vec<T>` is already on the heap, `Vec<Box<T>>` makes an extra allocation.", "`Vec<T>` is already on the heap, the boxing is unnecessary.",
"try", "try",
format!("Vec<{}>", boxed_type), format!("Vec<{}>", boxed_type),
Applicability::MachineApplicable Applicability::MaybeIncorrect,
) );
return; // don't recurse into the type
} }
} }
} else if match_def_path(cx.tcx, def_id, &paths::OPTION) { } else if match_def_path(cx.tcx, def_id, &paths::OPTION) {

View File

@@ -1,10 +1,10 @@
error: you seem to be trying to use `Vec<Box<T>>`, but T is Sized. `Vec<T>` is already on the heap, `Vec<Box<T>>` makes an extra allocation. error: `Vec<T>` is already on the heap, the boxing is unnecessary.
--> $DIR/vec_box_sized.rs:10:14 --> $DIR/vec_box_sized.rs:10:14
| |
10 | sized_type: Vec<Box<SizedStruct>>, 10 | sized_type: Vec<Box<SizedStruct>>,
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>` | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>`
| |
= note: `-D clippy::vec-box-sized` implied by `-D warnings` = note: `-D clippy::vec-box` implied by `-D warnings`
error: aborting due to previous error error: aborting due to previous error