]> git.lizzy.rs Git - rust.git/commitdiff
Capitalize safety comments
authorFlying-Toast <38232168+Flying-Toast@users.noreply.github.com>
Wed, 9 Sep 2020 02:26:44 +0000 (22:26 -0400)
committerFlying-Toast <38232168+Flying-Toast@users.noreply.github.com>
Wed, 9 Sep 2020 02:26:44 +0000 (22:26 -0400)
15 files changed:
library/core/src/future/mod.rs
library/core/src/iter/adapters/fuse.rs
library/core/src/iter/adapters/mod.rs
library/core/src/iter/adapters/zip.rs
library/core/src/lazy.rs
library/core/src/mem/maybe_uninit.rs
library/core/src/num/mod.rs
library/core/src/pin.rs
library/core/src/slice/mod.rs
library/std/src/alloc.rs
library/std/src/ffi/c_str.rs
library/std/src/ffi/os_str.rs
library/std/src/lazy.rs
library/std/src/sys/windows/os_str.rs
library/std/src/sys_common/os_str_bytes.rs

index 8b3df76f71fdda130f7fde6fc14dbb5b1a69de36..ddce0fe4b7dc5f8bdf7becdd22d9839267cf22b7 100644 (file)
@@ -71,7 +71,7 @@ impl<T: Generator<ResumeTy, Yield = ()>> !Unpin for GenFuture<T> {}
     impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> {
         type Output = T::Return;
         fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
-            // Safety: Safe because we're !Unpin + !Drop, and this is just a field projection.
+            // SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection.
             let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };
 
             // Resume the generator, turning the `&mut Context` into a `NonNull` raw pointer. The
index 4185453ac5ae331adb51becd0a7ef98a75cda2f7..409f202780ba6db876a94f3c3412c5181245f624 100644 (file)
@@ -530,7 +530,7 @@ unsafe impl<S: Iterator, I: FusedIterator> SourceIter for Fuse<I>
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
         match self.iter {
-            // Safety: unsafe function forwarding to unsafe function with the same requirements
+            // SAFETY: unsafe function forwarding to unsafe function with the same requirements
             Some(ref mut iter) => unsafe { SourceIter::as_inner(iter) },
             // SAFETY: the specialized iterator never sets `None`
             None => unsafe { intrinsics::unreachable() },
index b411222856edbf2fa795fd0e2cd3300163095b82..ab27fe15a8e2c5f26c335c60b5b2875ba755e201 100644 (file)
@@ -1019,7 +1019,7 @@ unsafe impl<S: Iterator, B, I: Iterator, F> SourceIter for Map<I, F>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -1168,7 +1168,7 @@ unsafe impl<S: Iterator, P, I: Iterator> SourceIter for Filter<I, P>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -1312,7 +1312,7 @@ unsafe impl<S: Iterator, B, I: Iterator, F> SourceIter for FilterMap<I, F>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -1550,7 +1550,7 @@ unsafe impl<S: Iterator, I: Iterator> SourceIter for Enumerate<I>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -1848,7 +1848,7 @@ unsafe impl<S: Iterator, I: Iterator> SourceIter for Peekable<I>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -1967,7 +1967,7 @@ unsafe impl<S: Iterator, P, I: Iterator> SourceIter for SkipWhile<I, P>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -2102,7 +2102,7 @@ unsafe impl<S: Iterator, P, I: Iterator> SourceIter for TakeWhile<I, P>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -2200,7 +2200,7 @@ unsafe impl<S: Iterator, B, I: Iterator, P> SourceIter for MapWhile<I, P>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -2403,7 +2403,7 @@ unsafe impl<S: Iterator, I: Iterator> SourceIter for Skip<I>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -2530,7 +2530,7 @@ unsafe impl<S: Iterator, I: Iterator> SourceIter for Take<I>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -2712,7 +2712,7 @@ unsafe impl<St, F, B, S: Iterator, I: Iterator> SourceIter for Scan<I, St, F>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
@@ -2879,7 +2879,7 @@ unsafe impl<S: Iterator, I: Iterator, F> SourceIter for Inspect<I, F>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.iter) }
     }
 }
index c1c90ec9a836aa4790bc5b169cdb61a1fd878da0..e02de0ce45dff75156d2978ff7987268cb3dc24c 100644 (file)
@@ -343,7 +343,7 @@ unsafe impl<S, A, B> SourceIter for Zip<A, B>
 
     #[inline]
     unsafe fn as_inner(&mut self) -> &mut S {
-        // Safety: unsafe function forwarding to unsafe function with the same requirements
+        // SAFETY: unsafe function forwarding to unsafe function with the same requirements
         unsafe { SourceIter::as_inner(&mut self.a) }
     }
 }
index 5cf7217ef11e81724f0c34482f1f9b18a780a063..2c517371c2c9bbccf80bffc7880136e64f85c33e 100644 (file)
@@ -92,7 +92,7 @@ pub const fn new() -> OnceCell<T> {
     /// Returns `None` if the cell is empty.
     #[unstable(feature = "once_cell", issue = "74465")]
     pub fn get(&self) -> Option<&T> {
-        // Safety: Safe due to `inner`'s invariant
+        // SAFETY: Safe due to `inner`'s invariant
         unsafe { &*self.inner.get() }.as_ref()
     }
 
@@ -101,7 +101,7 @@ pub fn get(&self) -> Option<&T> {
     /// Returns `None` if the cell is empty.
     #[unstable(feature = "once_cell", issue = "74465")]
     pub fn get_mut(&mut self) -> Option<&mut T> {
-        // Safety: Safe because we have unique access
+        // SAFETY: Safe because we have unique access
         unsafe { &mut *self.inner.get() }.as_mut()
     }
 
@@ -129,13 +129,13 @@ pub fn get_mut(&mut self) -> Option<&mut T> {
     /// ```
     #[unstable(feature = "once_cell", issue = "74465")]
     pub fn set(&self, value: T) -> Result<(), T> {
-        // Safety: Safe because we cannot have overlapping mutable borrows
+        // SAFETY: Safe because we cannot have overlapping mutable borrows
         let slot = unsafe { &*self.inner.get() };
         if slot.is_some() {
             return Err(value);
         }
 
-        // Safety: This is the only place where we set the slot, no races
+        // SAFETY: This is the only place where we set the slot, no races
         // due to reentrancy/concurrency are possible, and we've
         // checked that slot is currently `None`, so this write
         // maintains the `inner`'s invariant.
index b64abf68c5e4a6184d0af45d889e7f1cba0891f2..3a7489aa27955870992f6a9031390aeef467fa13 100644 (file)
@@ -599,7 +599,7 @@ pub unsafe fn read(&self) -> T {
     /// // Now that our `MaybeUninit<_>` is known to be initialized, it is okay to
     /// // create a shared reference to it:
     /// let x: &Vec<u32> = unsafe {
-    ///     // Safety: `x` has been initialized.
+    ///     // SAFETY: `x` has been initialized.
     ///     x.assume_init_ref()
     /// };
     /// assert_eq!(x, &vec![1, 2, 3]);
@@ -676,7 +676,7 @@ pub unsafe fn assume_init_ref(&self) -> &T {
     /// // To assert our buffer has been initialized without copying it, we upgrade
     /// // the `&mut MaybeUninit<[u8; 2048]>` to a `&mut [u8; 2048]`:
     /// let buf: &mut [u8; 2048] = unsafe {
-    ///     // Safety: `buf` has been initialized.
+    ///     // SAFETY: `buf` has been initialized.
     ///     buf.assume_init_mut()
     /// };
     ///
index 757ad5252bab3221bc2f6e5016c8880219f8913b..2a936c1867da00e63c50e5a07429dba4b84986bd 100644 (file)
@@ -124,7 +124,7 @@ impl BitOr for $Ty {
                 type Output = Self;
                 #[inline]
                 fn bitor(self, rhs: Self) -> Self::Output {
-                    // Safety: since `self` and `rhs` are both nonzero, the
+                    // SAFETY: since `self` and `rhs` are both nonzero, the
                     // result of the bitwise-or will be nonzero.
                     unsafe { $Ty::new_unchecked(self.get() | rhs.get()) }
                 }
@@ -135,7 +135,7 @@ impl BitOr<$Int> for $Ty {
                 type Output = Self;
                 #[inline]
                 fn bitor(self, rhs: $Int) -> Self::Output {
-                    // Safety: since `self` is nonzero, the result of the
+                    // SAFETY: since `self` is nonzero, the result of the
                     // bitwise-or will be nonzero regardless of the value of
                     // `rhs`.
                     unsafe { $Ty::new_unchecked(self.get() | rhs) }
@@ -147,7 +147,7 @@ impl BitOr<$Ty> for $Int {
                 type Output = $Ty;
                 #[inline]
                 fn bitor(self, rhs: $Ty) -> Self::Output {
-                    // Safety: since `rhs` is nonzero, the result of the
+                    // SAFETY: since `rhs` is nonzero, the result of the
                     // bitwise-or will be nonzero regardless of the value of
                     // `self`.
                     unsafe { $Ty::new_unchecked(self | rhs.get()) }
index 3c3bb68c671443345fd5eaa2b8ba68778eebd90e..1cc1dfb01433556f6bf20ad47374af1fbae190e5 100644 (file)
@@ -474,7 +474,7 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
     #[stable(feature = "pin", since = "1.33.0")]
     #[inline(always)]
     pub fn new(pointer: P) -> Pin<P> {
-        // Safety: the value pointed to is `Unpin`, and so has no requirements
+        // SAFETY: the value pointed to is `Unpin`, and so has no requirements
         // around pinning.
         unsafe { Pin::new_unchecked(pointer) }
     }
index c274ddf81bb8a16be070a24628d046efb7ebcac3..ce3a17a0d28e4d44d33805a0304247debd0e3552 100644 (file)
@@ -3245,7 +3245,7 @@ fn is_ascii(s: &[u8]) -> bool {
             (word_ptr as usize) - (start as usize) == byte_pos
         );
 
-        // Safety: We know `word_ptr` is properly aligned (because of
+        // SAFETY: We know `word_ptr` is properly aligned (because of
         // `align_offset`), and we know that we have enough bytes between `word_ptr` and the end
         let word = unsafe { word_ptr.read() };
         if contains_nonascii(word) {
index 64d8edf33bd3bcf393e9d94e028f3ea07849a8e0..770c97899f00253b5f429547e0d19c35696dacd6 100644 (file)
@@ -149,7 +149,7 @@ fn alloc_impl(&mut self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>,
         }
     }
 
-    // Safety: Same as `AllocRef::grow`
+    // SAFETY: Same as `AllocRef::grow`
     #[inline]
     unsafe fn grow_impl(
         &mut self,
index 51deb217c7c29a3b8e06fccb1d40e473082927fd..13021738af139fe3635d0271308c1309400e5ba7 100644 (file)
@@ -881,13 +881,13 @@ fn from(v: Vec<NonZeroU8>) -> CString {
         unsafe {
             // Transmute `Vec<NonZeroU8>` to `Vec<u8>`.
             let v: Vec<u8> = {
-                // Safety:
+                // SAFETY:
                 //   - transmuting between `NonZeroU8` and `u8` is sound;
                 //   - `alloc::Layout<NonZeroU8> == alloc::Layout<u8>`.
                 let (ptr, len, cap): (*mut NonZeroU8, _, _) = Vec::into_raw_parts(v);
                 Vec::from_raw_parts(ptr.cast::<u8>(), len, cap)
             };
-            // Safety: `v` cannot contain null bytes, given the type-level
+            // SAFETY: `v` cannot contain null bytes, given the type-level
             // invariant of `NonZeroU8`.
             CString::from_vec_unchecked(v)
         }
index e0be6d1c836aea9456a45197303778cfdce4c582..c83e996634c8a6e79ca4a9637c898f106fdad6ee 100644 (file)
@@ -510,14 +510,14 @@ pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr {
 
     #[inline]
     fn from_inner(inner: &Slice) -> &OsStr {
-        // Safety: OsStr is just a wrapper of Slice,
+        // SAFETY: OsStr is just a wrapper of Slice,
         // therefore converting &Slice to &OsStr is safe.
         unsafe { &*(inner as *const Slice as *const OsStr) }
     }
 
     #[inline]
     fn from_inner_mut(inner: &mut Slice) -> &mut OsStr {
-        // Safety: OsStr is just a wrapper of Slice,
+        // SAFETY: OsStr is just a wrapper of Slice,
         // therefore converting &mut Slice to &mut OsStr is safe.
         // Any method that mutates OsStr must be careful not to
         // break platform-specific encoding, in particular Wtf8 on Windows.
index d171231b0f1e63f1fc1c53731c85e8433b37520d..091e2091fb09576c37a259d3a8a408583aef9298 100644 (file)
@@ -293,7 +293,7 @@ pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E>
 
         debug_assert!(self.is_initialized());
 
-        // Safety: The inner value has been initialized
+        // SAFETY: The inner value has been initialized
         Ok(unsafe { self.get_unchecked() })
     }
 
@@ -316,7 +316,7 @@ pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E>
     /// ```
     #[unstable(feature = "once_cell", issue = "74465")]
     pub fn into_inner(mut self) -> Option<T> {
-        // Safety: Safe because we immediately free `self` without dropping
+        // SAFETY: Safe because we immediately free `self` without dropping
         let inner = unsafe { self.take_inner() };
 
         // Don't drop this `SyncOnceCell`. We just moved out one of the fields, but didn't set
@@ -416,7 +416,7 @@ unsafe fn get_unchecked_mut(&mut self) -> &mut T {
 
 unsafe impl<#[may_dangle] T> Drop for SyncOnceCell<T> {
     fn drop(&mut self) {
-        // Safety: The cell is being dropped, so it can't be accessed again.
+        // SAFETY: The cell is being dropped, so it can't be accessed again.
         // We also don't touch the `T`, which validates our usage of #[may_dangle].
         unsafe { self.take_inner() };
     }
index 2f5fc72ab44c2553ede8bffee6c8e506ee94957a..7e09a4fd5613036c02801d9a0851ca694b5e74f5 100644 (file)
@@ -77,14 +77,14 @@ pub fn from_string(s: String) -> Buf {
     }
 
     pub fn as_slice(&self) -> &Slice {
-        // Safety: Slice is just a wrapper for Wtf8,
+        // SAFETY: Slice is just a wrapper for Wtf8,
         // and self.inner.as_slice() returns &Wtf8.
         // Therefore, transmuting &Wtf8 to &Slice is safe.
         unsafe { mem::transmute(self.inner.as_slice()) }
     }
 
     pub fn as_mut_slice(&mut self) -> &mut Slice {
-        // Safety: Slice is just a wrapper for Wtf8,
+        // SAFETY: Slice is just a wrapper for Wtf8,
         // and self.inner.as_mut_slice() returns &mut Wtf8.
         // Therefore, transmuting &mut Wtf8 to &mut Slice is safe.
         // Additionally, care should be taken to ensure the slice
index 323165cda6bd5387f7cdf2bd9f4f1d8adff42070..497e5fc7bdd166c959d4572467db7f12bd1a1361 100644 (file)
@@ -106,7 +106,7 @@ pub fn shrink_to(&mut self, min_capacity: usize) {
 
     #[inline]
     pub fn as_slice(&self) -> &Slice {
-        // Safety: Slice just wraps [u8],
+        // SAFETY: Slice just wraps [u8],
         // and &*self.inner is &[u8], therefore
         // transmuting &[u8] to &Slice is safe.
         unsafe { mem::transmute(&*self.inner) }
@@ -114,7 +114,7 @@ pub fn as_slice(&self) -> &Slice {
 
     #[inline]
     pub fn as_mut_slice(&mut self) -> &mut Slice {
-        // Safety: Slice just wraps [u8],
+        // SAFETY: Slice just wraps [u8],
         // and &mut *self.inner is &mut [u8], therefore
         // transmuting &mut [u8] to &mut Slice is safe.
         unsafe { mem::transmute(&mut *self.inner) }