about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/std/src/sys/pal/common/small_c_string.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sys/pal/common/small_c_string.rs b/library/std/src/sys/pal/common/small_c_string.rs
index 2312e6e5ee2..8e5ecdea9a8 100644
--- a/library/std/src/sys/pal/common/small_c_string.rs
+++ b/library/std/src/sys/pal/common/small_c_string.rs
@@ -27,6 +27,8 @@ pub fn run_with_cstr<T, F>(bytes: &[u8], mut f: F) -> io::Result<T>
 where
     F: FnMut(&CStr) -> io::Result<T>,
 {
+    // Dispatch and dyn erase the closure type to prevent mono bloat.
+    // See https://github.com/rust-lang/rust/pull/121101.
     if bytes.len() >= MAX_STACK_ALLOCATION {
         run_with_cstr_allocating(bytes, &mut f)
     } else {
@@ -34,6 +36,9 @@ where
     }
 }
 
+/// # Safety
+///
+/// `bytes` must have a length less than `MAX_STACK_ALLOCATION`.
 unsafe fn run_with_cstr_stack<T>(
     bytes: &[u8],
     f: &mut dyn FnMut(&CStr) -> io::Result<T>,