Skip to content

Commit

Permalink
Unrolled build for rust-lang#136775
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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.

rust-lang#119206 (comment)
  • Loading branch information
rust-timer authored Feb 25, 2025
2 parents f5729cf + 562880c commit fe33324
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,11 +966,8 @@ impl String {
/// 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
Expand Down

0 comments on commit fe33324

Please sign in to comment.