diff options
Diffstat (limited to 'vendor/rustix/src/path')
-rw-r--r-- | vendor/rustix/src/path/arg.rs | 8 | ||||
-rw-r--r-- | vendor/rustix/src/path/dec_int.rs | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/vendor/rustix/src/path/arg.rs b/vendor/rustix/src/path/arg.rs index 0ea673d19..3d976ce3e 100644 --- a/vendor/rustix/src/path/arg.rs +++ b/vendor/rustix/src/path/arg.rs @@ -41,7 +41,7 @@ use std::path::{Component, Components, Iter, Path, PathBuf}; /// /// # Example /// -/// ```rust +/// ``` /// # #[cfg(any(feature = "fs", feature = "net"))] /// use rustix::ffi::CStr; /// use rustix::io; @@ -950,13 +950,15 @@ where } // Taken from - // https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs + // <https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs> let mut buf = MaybeUninit::<[u8; SMALL_PATH_BUFFER_SIZE]>::uninit(); let buf_ptr = buf.as_mut_ptr() as *mut u8; + // This helps test our safety condition below. + debug_assert!(bytes.len() + 1 <= SMALL_PATH_BUFFER_SIZE); + // SAFETY: bytes.len() < SMALL_PATH_BUFFER_SIZE which means we have space for // bytes.len() + 1 u8s: - debug_assert!(bytes.len() + 1 <= SMALL_PATH_BUFFER_SIZE); unsafe { ptr::copy_nonoverlapping(bytes.as_ptr(), buf_ptr, bytes.len()); buf_ptr.add(bytes.len()).write(0); diff --git a/vendor/rustix/src/path/dec_int.rs b/vendor/rustix/src/path/dec_int.rs index d0975694b..5ba8be4fc 100644 --- a/vendor/rustix/src/path/dec_int.rs +++ b/vendor/rustix/src/path/dec_int.rs @@ -30,7 +30,7 @@ use std::path::Path; /// /// # Example /// -/// ```rust +/// ``` /// # #[cfg(feature = "path")] /// use rustix::path::DecInt; /// @@ -70,7 +70,7 @@ impl DecInt { /// Return the raw byte buffer as a `&str`. #[inline] pub fn as_str(&self) -> &str { - // Safety: `DecInt` always holds a formatted decimal number, so it's + // SAFETY: `DecInt` always holds a formatted decimal number, so it's // always valid UTF-8. unsafe { core::str::from_utf8_unchecked(self.as_bytes()) } } @@ -81,7 +81,7 @@ impl DecInt { let bytes_with_nul = &self.buf[..=self.len]; debug_assert!(CStr::from_bytes_with_nul(bytes_with_nul).is_ok()); - // Safety: `self.buf` holds a single decimal ASCII representation and + // SAFETY: `self.buf` holds a single decimal ASCII representation and // at least one extra NUL byte. unsafe { CStr::from_bytes_with_nul_unchecked(bytes_with_nul) } } |