Skip to content

Commit c18fa46

Browse files
authored
Rollup merge of #76504 - Flying-Toast:master, r=lcnr
Capitalize safety comments
2 parents 342b406 + 2799aec commit c18fa46

File tree

19 files changed

+42
-42
lines changed

19 files changed

+42
-42
lines changed

compiler/rustc_data_structures/src/temp_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct MaybeTempDir {
1212

1313
impl Drop for MaybeTempDir {
1414
fn drop(&mut self) {
15-
// Safety: We are in the destructor, and no further access will
15+
// SAFETY: We are in the destructor, and no further access will
1616
// occur.
1717
let dir = unsafe { ManuallyDrop::take(&mut self.dir) };
1818
if self.keep {

library/alloc/src/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl Global {
157157
}
158158
}
159159

160-
// Safety: Same as `AllocRef::grow`
160+
// SAFETY: Same as `AllocRef::grow`
161161
#[inline]
162162
unsafe fn grow_impl(
163163
&mut self,

library/alloc/src/collections/vec_deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,7 @@ impl<T> VecDeque<T> {
23882388
}
23892389
}
23902390

2391-
// Safety: the following two methods require that the rotation amount
2391+
// SAFETY: the following two methods require that the rotation amount
23922392
// be less than half the length of the deque.
23932393
//
23942394
// `wrap_copy` requires that `min(x, cap() - x) + copy_len <= cap()`,

library/core/src/future/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ where
7171
impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> {
7272
type Output = T::Return;
7373
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
74-
// Safety: Safe because we're !Unpin + !Drop, and this is just a field projection.
74+
// SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection.
7575
let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };
7676

7777
// Resume the generator, turning the `&mut Context` into a `NonNull` raw pointer. The

library/core/src/iter/adapters/fuse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ where
530530
#[inline]
531531
unsafe fn as_inner(&mut self) -> &mut S {
532532
match self.iter {
533-
// Safety: unsafe function forwarding to unsafe function with the same requirements
533+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
534534
Some(ref mut iter) => unsafe { SourceIter::as_inner(iter) },
535535
// SAFETY: the specialized iterator never sets `None`
536536
None => unsafe { intrinsics::unreachable() },

library/core/src/iter/adapters/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ where
10191019

10201020
#[inline]
10211021
unsafe fn as_inner(&mut self) -> &mut S {
1022-
// Safety: unsafe function forwarding to unsafe function with the same requirements
1022+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
10231023
unsafe { SourceIter::as_inner(&mut self.iter) }
10241024
}
10251025
}
@@ -1168,7 +1168,7 @@ where
11681168

11691169
#[inline]
11701170
unsafe fn as_inner(&mut self) -> &mut S {
1171-
// Safety: unsafe function forwarding to unsafe function with the same requirements
1171+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
11721172
unsafe { SourceIter::as_inner(&mut self.iter) }
11731173
}
11741174
}
@@ -1312,7 +1312,7 @@ where
13121312

13131313
#[inline]
13141314
unsafe fn as_inner(&mut self) -> &mut S {
1315-
// Safety: unsafe function forwarding to unsafe function with the same requirements
1315+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
13161316
unsafe { SourceIter::as_inner(&mut self.iter) }
13171317
}
13181318
}
@@ -1550,7 +1550,7 @@ where
15501550

15511551
#[inline]
15521552
unsafe fn as_inner(&mut self) -> &mut S {
1553-
// Safety: unsafe function forwarding to unsafe function with the same requirements
1553+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
15541554
unsafe { SourceIter::as_inner(&mut self.iter) }
15551555
}
15561556
}
@@ -1848,7 +1848,7 @@ where
18481848

18491849
#[inline]
18501850
unsafe fn as_inner(&mut self) -> &mut S {
1851-
// Safety: unsafe function forwarding to unsafe function with the same requirements
1851+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
18521852
unsafe { SourceIter::as_inner(&mut self.iter) }
18531853
}
18541854
}
@@ -1967,7 +1967,7 @@ where
19671967

19681968
#[inline]
19691969
unsafe fn as_inner(&mut self) -> &mut S {
1970-
// Safety: unsafe function forwarding to unsafe function with the same requirements
1970+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
19711971
unsafe { SourceIter::as_inner(&mut self.iter) }
19721972
}
19731973
}
@@ -2102,7 +2102,7 @@ where
21022102

21032103
#[inline]
21042104
unsafe fn as_inner(&mut self) -> &mut S {
2105-
// Safety: unsafe function forwarding to unsafe function with the same requirements
2105+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
21062106
unsafe { SourceIter::as_inner(&mut self.iter) }
21072107
}
21082108
}
@@ -2200,7 +2200,7 @@ where
22002200

22012201
#[inline]
22022202
unsafe fn as_inner(&mut self) -> &mut S {
2203-
// Safety: unsafe function forwarding to unsafe function with the same requirements
2203+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
22042204
unsafe { SourceIter::as_inner(&mut self.iter) }
22052205
}
22062206
}
@@ -2403,7 +2403,7 @@ where
24032403

24042404
#[inline]
24052405
unsafe fn as_inner(&mut self) -> &mut S {
2406-
// Safety: unsafe function forwarding to unsafe function with the same requirements
2406+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
24072407
unsafe { SourceIter::as_inner(&mut self.iter) }
24082408
}
24092409
}
@@ -2530,7 +2530,7 @@ where
25302530

25312531
#[inline]
25322532
unsafe fn as_inner(&mut self) -> &mut S {
2533-
// Safety: unsafe function forwarding to unsafe function with the same requirements
2533+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
25342534
unsafe { SourceIter::as_inner(&mut self.iter) }
25352535
}
25362536
}
@@ -2712,7 +2712,7 @@ where
27122712

27132713
#[inline]
27142714
unsafe fn as_inner(&mut self) -> &mut S {
2715-
// Safety: unsafe function forwarding to unsafe function with the same requirements
2715+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
27162716
unsafe { SourceIter::as_inner(&mut self.iter) }
27172717
}
27182718
}
@@ -2879,7 +2879,7 @@ where
28792879

28802880
#[inline]
28812881
unsafe fn as_inner(&mut self) -> &mut S {
2882-
// Safety: unsafe function forwarding to unsafe function with the same requirements
2882+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
28832883
unsafe { SourceIter::as_inner(&mut self.iter) }
28842884
}
28852885
}

library/core/src/iter/adapters/zip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ where
343343

344344
#[inline]
345345
unsafe fn as_inner(&mut self) -> &mut S {
346-
// Safety: unsafe function forwarding to unsafe function with the same requirements
346+
// SAFETY: unsafe function forwarding to unsafe function with the same requirements
347347
unsafe { SourceIter::as_inner(&mut self.a) }
348348
}
349349
}

library/core/src/lazy.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<T> OnceCell<T> {
9292
/// Returns `None` if the cell is empty.
9393
#[unstable(feature = "once_cell", issue = "74465")]
9494
pub fn get(&self) -> Option<&T> {
95-
// Safety: Safe due to `inner`'s invariant
95+
// SAFETY: Safe due to `inner`'s invariant
9696
unsafe { &*self.inner.get() }.as_ref()
9797
}
9898

@@ -101,7 +101,7 @@ impl<T> OnceCell<T> {
101101
/// Returns `None` if the cell is empty.
102102
#[unstable(feature = "once_cell", issue = "74465")]
103103
pub fn get_mut(&mut self) -> Option<&mut T> {
104-
// Safety: Safe because we have unique access
104+
// SAFETY: Safe because we have unique access
105105
unsafe { &mut *self.inner.get() }.as_mut()
106106
}
107107

@@ -129,13 +129,13 @@ impl<T> OnceCell<T> {
129129
/// ```
130130
#[unstable(feature = "once_cell", issue = "74465")]
131131
pub fn set(&self, value: T) -> Result<(), T> {
132-
// Safety: Safe because we cannot have overlapping mutable borrows
132+
// SAFETY: Safe because we cannot have overlapping mutable borrows
133133
let slot = unsafe { &*self.inner.get() };
134134
if slot.is_some() {
135135
return Err(value);
136136
}
137137

138-
// Safety: This is the only place where we set the slot, no races
138+
// SAFETY: This is the only place where we set the slot, no races
139139
// due to reentrancy/concurrency are possible, and we've
140140
// checked that slot is currently `None`, so this write
141141
// maintains the `inner`'s invariant.

library/core/src/mem/maybe_uninit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl<T> MaybeUninit<T> {
599599
/// // Now that our `MaybeUninit<_>` is known to be initialized, it is okay to
600600
/// // create a shared reference to it:
601601
/// let x: &Vec<u32> = unsafe {
602-
/// // Safety: `x` has been initialized.
602+
/// // SAFETY: `x` has been initialized.
603603
/// x.assume_init_ref()
604604
/// };
605605
/// assert_eq!(x, &vec![1, 2, 3]);
@@ -676,7 +676,7 @@ impl<T> MaybeUninit<T> {
676676
/// // To assert our buffer has been initialized without copying it, we upgrade
677677
/// // the `&mut MaybeUninit<[u8; 2048]>` to a `&mut [u8; 2048]`:
678678
/// let buf: &mut [u8; 2048] = unsafe {
679-
/// // Safety: `buf` has been initialized.
679+
/// // SAFETY: `buf` has been initialized.
680680
/// buf.assume_init_mut()
681681
/// };
682682
///

library/core/src/num/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
124124
type Output = Self;
125125
#[inline]
126126
fn bitor(self, rhs: Self) -> Self::Output {
127-
// Safety: since `self` and `rhs` are both nonzero, the
127+
// SAFETY: since `self` and `rhs` are both nonzero, the
128128
// result of the bitwise-or will be nonzero.
129129
unsafe { $Ty::new_unchecked(self.get() | rhs.get()) }
130130
}
@@ -135,7 +135,7 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
135135
type Output = Self;
136136
#[inline]
137137
fn bitor(self, rhs: $Int) -> Self::Output {
138-
// Safety: since `self` is nonzero, the result of the
138+
// SAFETY: since `self` is nonzero, the result of the
139139
// bitwise-or will be nonzero regardless of the value of
140140
// `rhs`.
141141
unsafe { $Ty::new_unchecked(self.get() | rhs) }
@@ -147,7 +147,7 @@ assert_eq!(size_of::<Option<core::num::", stringify!($Ty), ">>(), size_of::<", s
147147
type Output = $Ty;
148148
#[inline]
149149
fn bitor(self, rhs: $Ty) -> Self::Output {
150-
// Safety: since `rhs` is nonzero, the result of the
150+
// SAFETY: since `rhs` is nonzero, the result of the
151151
// bitwise-or will be nonzero regardless of the value of
152152
// `self`.
153153
unsafe { $Ty::new_unchecked(self | rhs.get()) }

0 commit comments

Comments
 (0)