mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-29 11:51:31 +03:00
Rollup merge of #136775 - robertbastian:patch-2, r=Amanieu
Update `String::from_raw_parts` safety requirements These have become out of sync with `Vec::from_raw_part`'s safety requirements, and are likely to diverge again. I think it's safest to just point at `Vec`'s requirements. https://github.com/rust-lang/rust/issues/119206#issuecomment-2180116680
This commit is contained in:
@@ -966,11 +966,8 @@ pub fn into_raw_parts(self) -> (*mut u8, usize, usize) {
|
||||
/// This is highly unsafe, due to the number of invariants that aren't
|
||||
/// checked:
|
||||
///
|
||||
/// * The memory at `buf` needs to have been previously allocated by the
|
||||
/// same allocator the standard library uses, with a required alignment of exactly 1.
|
||||
/// * `length` needs to be less than or equal to `capacity`.
|
||||
/// * `capacity` needs to be the correct value.
|
||||
/// * The first `length` bytes at `buf` need to be valid UTF-8.
|
||||
/// * all safety requirements for [`Vec::<u8>::from_raw_parts`].
|
||||
/// * all safety requirements for [`String::from_utf8_unchecked`].
|
||||
///
|
||||
/// Violating these may cause problems like corrupting the allocator's
|
||||
/// internal data structures. For example, it is normally **not** safe to
|
||||
|
||||
Reference in New Issue
Block a user