Skip to content

Commit 26a6270

Browse files
committed
Update the comment
1 parent 6d43225 commit 26a6270

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/alloc/src/str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ where
163163
})
164164
.expect("attempt to join into collection with len > usize::MAX");
165165

166-
// crucial for safety
166+
// prepare an uninitialized buffer
167167
let mut result = Vec::with_capacity(reserved_len);
168168
debug_assert!(result.capacity() >= reserved_len);
169169

@@ -178,9 +178,9 @@ where
178178
// massive improvements possible (~ x2)
179179
let remain = specialize_for_lengths!(sep, target, iter; 0, 1, 2, 3, 4);
180180

181-
// issue #80335: A weird borrow implementation can return different
182-
// slices for the length calculation and the actual copy, so
183-
// `remain.len()` might be non-zero.
181+
// A weird borrow implementation may return different
182+
// slices for the length calculation and the actual copy.
183+
// Make sure we don't expose uninitialized bytes to the caller.
184184
let result_len = reserved_len - remain.len();
185185
result.set_len(result_len);
186186
}

0 commit comments

Comments
 (0)