diff --git a/library/core/src/io/borrowed_buf.rs b/library/core/src/io/borrowed_buf.rs index 7b03d58a3fd62..2cc1ebba1a85c 100644 --- a/library/core/src/io/borrowed_buf.rs +++ b/library/core/src/io/borrowed_buf.rs @@ -222,6 +222,14 @@ pub struct BorrowedCursor<'a, T> { borrowed_buf: NonNull>, } +// SAFETY: A `BorrowedCursor<'a, T>` is a unique borrow of a `BorrowedBuf<'a, T>`, which is a +// `&'a mut [MaybeUninit]` and two `Copy` fields. The `buf` raw pointer is used like +// `&mut [MaybeUninit]` so `T: Send` -> `Send` and is: `T: Sync` -> `Sync`, and the +// `borrowed_buf` only touches two `Copy` fields, without depending of `T`. +unsafe impl Send for BorrowedCursor<'_, T> {} +// SAFETY: See the `Send` impl above. +unsafe impl Sync for BorrowedCursor<'_, T> {} + impl Debug for BorrowedCursor<'_, T> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let buf = BorrowedBufDebug {