about summary refs log tree commit diff
path: root/library/std/src/path.rs
diff options
context:
space:
mode:
authorThalia Archibald <thalia@archibald.dev>2025-04-11 02:52:17 -0700
committerThalia Archibald <thalia@archibald.dev>2025-04-30 23:56:39 -0700
commit7cb357a36b96781f9ff85f8a4168382243352ba1 (patch)
tree67febe2b927678f6c4f937a790ada32e4fb712a1 /library/std/src/path.rs
parent9bfa31f632912180dc742809bcc51a97f2d7079d (diff)
downloadrust-7cb357a36b96781f9ff85f8a4168382243352ba1.tar.gz
rust-7cb357a36b96781f9ff85f8a4168382243352ba1.zip
Make internal `OsString::truncate` and `extend_from_slice` unsafe
Communicate the safety invariants of these methods with `unsafe fn`
rather than privacy.
Diffstat (limited to 'library/std/src/path.rs')
-rw-r--r--library/std/src/path.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index 50f403ba411..ae18891ad47 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -2759,7 +2759,8 @@ impl Path {
         };
 
         let mut new_path = PathBuf::with_capacity(new_capacity);
-        new_path.inner.extend_from_slice(slice_to_copy);
+        // SAFETY: The path is empty, so cannot have surrogate halves.
+        unsafe { new_path.inner.extend_from_slice_unchecked(slice_to_copy) };
         new_path.set_extension(extension);
         new_path
     }