mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Downgrade unsafe_vector_initialization to restriction
This lint looks for: let mut vec = Vec::with_capacity(len); vec.set_len(len); The suggested replacement is `vec![0; len]`. This is far too opinionated to be a deny-by-default lint because the performance characteristics of the suggested replacement are totally different. I am not convinced that this lint has value beyond what deny(unsafe_code) gives you. Unsafe code is unsafe but please don't deny-by-default lint it if that's the only reason.
This commit is contained in:
parent
c669727df4
commit
8b1f69a485
2 changed files with 2 additions and 3 deletions
|
@ -495,6 +495,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
panic_unimplemented::UNIMPLEMENTED,
|
||||
shadow::SHADOW_REUSE,
|
||||
shadow::SHADOW_SAME,
|
||||
slow_vector_initialization::UNSAFE_VECTOR_INITIALIZATION,
|
||||
strings::STRING_ADD,
|
||||
write::PRINT_STDOUT,
|
||||
write::USE_DEBUG,
|
||||
|
@ -727,7 +728,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
returns::UNUSED_UNIT,
|
||||
serde_api::SERDE_API_MISUSE,
|
||||
slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
|
||||
slow_vector_initialization::UNSAFE_VECTOR_INITIALIZATION,
|
||||
strings::STRING_LIT_AS_BYTES,
|
||||
suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
|
||||
suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
|
||||
|
@ -974,7 +974,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
ranges::ITERATOR_STEP_BY_ZERO,
|
||||
regex::INVALID_REGEX,
|
||||
serde_api::SERDE_API_MISUSE,
|
||||
slow_vector_initialization::UNSAFE_VECTOR_INITIALIZATION,
|
||||
suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
|
||||
suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
|
||||
swap::ALMOST_SWAPPED,
|
||||
|
|
|
@ -55,7 +55,7 @@ declare_clippy_lint! {
|
|||
/// ```
|
||||
declare_clippy_lint! {
|
||||
pub UNSAFE_VECTOR_INITIALIZATION,
|
||||
correctness,
|
||||
restriction,
|
||||
"unsafe vector initialization"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue