Skip to content

Commit 1e2291c

Browse files
authored
Merge pull request #3365 from gnieto/lint/slow-initialization
Add slow vector initializations lint
2 parents 03498fd + dc35841 commit 1e2291c

7 files changed

+561
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ All notable changes to this project will be documented in this file.
842842
[`single_char_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
843843
[`single_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match
844844
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
845+
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
845846
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
846847
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
847848
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign
@@ -880,6 +881,7 @@ All notable changes to this project will be documented in this file.
880881
[`unneeded_field_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
881882
[`unreadable_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal
882883
[`unsafe_removed_from_name`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_removed_from_name
884+
[`unsafe_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#unsafe_vector_initialization
883885
[`unseparated_literal_suffix`]: https://rust-lang.github.io/rust-clippy/master/index.html#unseparated_literal_suffix
884886
[`unstable_as_mut_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_mut_slice
885887
[`unstable_as_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#unstable_as_slice

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We are currently in the process of discussing Clippy 1.0 via the RFC process in
99

1010
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
1111

12-
[There are 288 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
12+
[There are 290 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1313

1414
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1515

clippy_lints/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ pub mod replace_consts;
190190
pub mod returns;
191191
pub mod serde_api;
192192
pub mod shadow;
193+
pub mod slow_vector_initialization;
193194
pub mod strings;
194195
pub mod suspicious_trait_impl;
195196
pub mod swap;
@@ -459,6 +460,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
459460
reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
460461
reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
461462
reg.register_late_lint_pass(box redundant_clone::RedundantClone);
463+
reg.register_late_lint_pass(box slow_vector_initialization::Pass);
462464

463465
reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
464466
arithmetic::FLOAT_ARITHMETIC,
@@ -709,6 +711,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
709711
returns::NEEDLESS_RETURN,
710712
returns::UNUSED_UNIT,
711713
serde_api::SERDE_API_MISUSE,
714+
slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
715+
slow_vector_initialization::UNSAFE_VECTOR_INITIALIZATION,
712716
strings::STRING_LIT_AS_BYTES,
713717
suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
714718
suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
@@ -955,6 +959,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
955959
ranges::ITERATOR_STEP_BY_ZERO,
956960
regex::INVALID_REGEX,
957961
serde_api::SERDE_API_MISUSE,
962+
slow_vector_initialization::UNSAFE_VECTOR_INITIALIZATION,
958963
suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
959964
suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
960965
swap::ALMOST_SWAPPED,
@@ -980,6 +985,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
980985
methods::SINGLE_CHAR_PATTERN,
981986
misc::CMP_OWNED,
982987
mutex_atomic::MUTEX_ATOMIC,
988+
slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
983989
trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
984990
types::BOX_VEC,
985991
vec::USELESS_VEC,

0 commit comments

Comments
 (0)