Skip to content

Commit 5abd484

Browse files
tgross35gitbot
authored and
gitbot
committed
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)
2 parents 3bf9c33 + 4f39af5 commit 5abd484

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

alloc/src/string.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,8 @@ impl String {
966966
/// This is highly unsafe, due to the number of invariants that aren't
967967
/// checked:
968968
///
969-
/// * The memory at `buf` needs to have been previously allocated by the
970-
/// same allocator the standard library uses, with a required alignment of exactly 1.
971-
/// * `length` needs to be less than or equal to `capacity`.
972-
/// * `capacity` needs to be the correct value.
973-
/// * The first `length` bytes at `buf` need to be valid UTF-8.
969+
/// * all safety requirements for [`Vec::<u8>::from_raw_parts`].
970+
/// * all safety requirements for [`String::from_utf8_unchecked`].
974971
///
975972
/// Violating these may cause problems like corrupting the allocator's
976973
/// internal data structures. For example, it is normally **not** safe to

0 commit comments

Comments
 (0)