diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2025-02-24 18:46:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-24 18:46:35 -0500 |
| commit | 03326daf23ea67499e0a67fa2db871650faf5348 (patch) | |
| tree | ecf4a9403460d6e8629fc567826fcc2cf0330d75 /library/alloc/src/string.rs | |
| parent | fe2876fcba2abaaed814352786dd085593bfed65 (diff) | |
| parent | 562880cfd96b4bf856ad4af1c3803fb75dc7bba9 (diff) | |
| download | rust-03326daf23ea67499e0a67fa2db871650faf5348.tar.gz rust-03326daf23ea67499e0a67fa2db871650faf5348.zip | |
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
Diffstat (limited to 'library/alloc/src/string.rs')
| -rw-r--r-- | library/alloc/src/string.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 9446afd4b24..f10ef1fca13 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -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 |
