Skip to content

Commit 4ed3a4f

Browse files
committed
Update lint description for new() and default()
1 parent 03fed75 commit 4ed3a4f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

clippy_lints/src/uninit_vec.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ use rustc_span::{sym, Span};
1313
declare_clippy_lint! {
1414
/// ### What it does
1515
/// Checks for `set_len()` call that creates `Vec` with uninitialized elements.
16-
/// This is commonly caused by calling `set_len()` right after after calling
17-
/// `with_capacity()` or `reserve()`.
16+
/// This is commonly caused by calling `set_len()` right after allocating or
17+
/// reserving a buffer with `new()`, `default()`, `with_capacity()`, or `reserve()`.
1818
///
1919
/// ### Why is this bad?
2020
/// It creates a `Vec` with uninitialized data, which leads to
21-
/// undefined behavior with most safe operations.
21+
/// undefined behavior with most safe operations. Notably, uninitialized
22+
/// `Vec<u8>` must not be used with generic `Read`.
2223
///
23-
/// Notably, uninitialized `Vec<u8>` must not be used with generic `Read`.
24+
/// Moreover, calling `set_len()` on a `Vec` created with `new()` or `default()`
25+
/// creates out-of-bound values that lead to heap memory corruption when used.
2426
///
2527
/// ### Known Problems
2628
/// This lint only checks directly adjacent statements.

0 commit comments

Comments
 (0)