Skip to content

Commit db00c33

Browse files
committed
Remove references to sized for end users
1 parent 9fc914c commit db00c33

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ All notable changes to this project will be documented in this file.
899899
[`useless_let_if_seq`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_let_if_seq
900900
[`useless_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_transmute
901901
[`useless_vec`]: https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec
902-
[`vec_box_sized`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_box_sized
902+
[`vec_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#vec_box
903903
[`verbose_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask
904904
[`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
905905
[`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop

clippy_lints/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
766766
types::UNIT_ARG,
767767
types::UNIT_CMP,
768768
types::UNNECESSARY_CAST,
769-
types::VEC_BOX_SIZED,
769+
types::VEC_BOX,
770770
unicode::ZERO_WIDTH_SPACE,
771771
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
772772
unused_io_amount::UNUSED_IO_AMOUNT,
@@ -932,7 +932,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
932932
types::TYPE_COMPLEXITY,
933933
types::UNIT_ARG,
934934
types::UNNECESSARY_CAST,
935-
types::VEC_BOX_SIZED,
935+
types::VEC_BOX,
936936
unused_label::UNUSED_LABEL,
937937
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
938938
]);

clippy_lints/src/types.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ declare_clippy_lint! {
9090
/// }
9191
/// ```
9292
declare_clippy_lint! {
93-
pub VEC_BOX_SIZED,
93+
pub VEC_BOX,
9494
complexity,
9595
"usage of `Vec<Box<T>>` where T: Sized, vector elements are already on the heap"
9696
}
@@ -175,7 +175,7 @@ declare_clippy_lint! {
175175

176176
impl LintPass for TypePass {
177177
fn get_lints(&self) -> LintArray {
178-
lint_array!(BOX_VEC, VEC_BOX_SIZED, OPTION_OPTION, LINKEDLIST, BORROWED_BOX)
178+
lint_array!(BOX_VEC, VEC_BOX, OPTION_OPTION, LINKEDLIST, BORROWED_BOX)
179179
}
180180
}
181181

@@ -292,13 +292,14 @@ fn check_ty(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool) {
292292
then {
293293
span_lint_and_sugg(
294294
cx,
295-
VEC_BOX_SIZED,
295+
VEC_BOX,
296296
ast_ty.span,
297-
"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.",
297+
"`Vec<T>` is already on the heap, the boxing is unnecessary.",
298298
"try",
299299
format!("Vec<{}>", boxed_type),
300-
Applicability::MachineApplicable
301-
)
300+
Applicability::MaybeIncorrect,
301+
);
302+
return; // don't recurse into the type
302303
}
303304
}
304305
} else if match_def_path(cx.tcx, def_id, &paths::OPTION) {

tests/ui/vec_box_sized.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
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.
1+
error: `Vec<T>` is already on the heap, the boxing is unnecessary.
22
--> $DIR/vec_box_sized.rs:10:14
33
|
44
10 | sized_type: Vec<Box<SizedStruct>>,
55
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<SizedStruct>`
66
|
7-
= note: `-D clippy::vec-box-sized` implied by `-D warnings`
7+
= note: `-D clippy::vec-box` implied by `-D warnings`
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)