]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/wasi/ext/fs.rs
Auto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum
[rust.git] / library / std / src / sys / wasi / ext / fs.rs
index f41c6626ccf120824fb683d8a5d850d471886a9d..4f7cf6018d90fe99d9b2be792c86e84c6c71fe6b 100644 (file)
@@ -1,5 +1,6 @@
 //! WASI-specific extensions to primitives in the `std::fs` module.
 
+#![deny(unsafe_op_in_unsafe_fn)]
 #![unstable(feature = "wasi_ext", issue = "none")]
 
 use crate::fs::{self, File, Metadata, OpenOptions};
@@ -9,8 +10,6 @@
 use crate::sys_common::{AsInner, AsInnerMut, FromInner};
 
 /// WASI-specific extensions to [`File`].
-///
-/// [`File`]: ../../../../std/fs/struct.File.html
 pub trait FileExt {
     /// Reads a number of bytes starting from a given offset.
     ///
@@ -23,8 +22,6 @@ pub trait FileExt {
     ///
     /// Note that similar to [`File::read`], it is not an error to return with a
     /// short read.
-    ///
-    /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read
     fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
         let bufs = &mut [IoSliceMut::new(buf)];
         self.read_vectored_at(bufs, offset)
@@ -41,8 +38,6 @@ fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
     ///
     /// Note that similar to [`File::read_vectored`], it is not an error to
     /// return with a short read.
-    ///
-    /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read_vectored
     fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize>;
 
     /// Reads the exact number of byte required to fill `buf` from the given offset.
@@ -54,8 +49,7 @@ fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
     ///
     /// Similar to [`Read::read_exact`] but uses [`read_at`] instead of `read`.
     ///
-    /// [`Read::read_exact`]: ../../../../std/io/trait.Read.html#method.read_exact
-    /// [`read_at`]: #tymethod.read_at
+    /// [`read_at`]: FileExt::read_at
     ///
     /// # Errors
     ///
@@ -73,9 +67,6 @@ fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
     /// If this function returns an error, it is unspecified how many bytes it
     /// has read, but it will never read more than would be necessary to
     /// completely fill the buffer.
-    ///
-    /// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted
-    /// [`ErrorKind::UnexpectedEof`]: ../../../../std/io/enum.ErrorKind.html#variant.UnexpectedEof
     #[stable(feature = "rw_exact_all_at", since = "1.33.0")]
     fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> {
         while !buf.is_empty() {
@@ -111,8 +102,6 @@ fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> {
     ///
     /// Note that similar to [`File::write`], it is not an error to return a
     /// short write.
-    ///
-    /// [`File::write`]: ../../../../std/fs/struct.File.html#write.v
     fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
         let bufs = &[IoSlice::new(buf)];
         self.write_vectored_at(bufs, offset)
@@ -132,8 +121,6 @@ fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
     ///
     /// Note that similar to [`File::write_vectored`], it is not an error to return a
     /// short write.
-    ///
-    /// [`File::write`]: ../../../../std/fs/struct.File.html#method.write_vectored
     fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize>;
 
     /// Attempts to write an entire buffer starting from a given offset.
@@ -155,8 +142,7 @@ fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
     /// This function will return the first error of
     /// non-[`ErrorKind::Interrupted`] kind that [`write_at`] returns.
     ///
-    /// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted
-    /// [`write_at`]: #tymethod.write_at
+    /// [`write_at`]: FileExt::write_at
     #[stable(feature = "rw_exact_all_at", since = "1.33.0")]
     fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> {
         while !buf.is_empty() {
@@ -289,8 +275,6 @@ fn remove_directory<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
 }
 
 /// WASI-specific extensions to [`fs::OpenOptions`].
-///
-/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html
 pub trait OpenOptionsExt {
     /// Pass custom `dirflags` argument to `path_open`.
     ///
@@ -406,8 +390,6 @@ fn open_at<P: AsRef<Path>>(&self, file: &File, path: P) -> io::Result<File> {
 }
 
 /// WASI-specific extensions to [`fs::Metadata`].
-///
-/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
 pub trait MetadataExt {
     /// Returns the `st_dev` field of the internal `filestat_t`
     fn dev(&self) -> u64;
@@ -448,8 +430,6 @@ fn ctim(&self) -> u64 {
 ///
 /// Adds support for special WASI file types such as block/character devices,
 /// pipes, and sockets.
-///
-/// [`FileType`]: ../../../../std/fs/struct.FileType.html
 pub trait FileTypeExt {
     /// Returns `true` if this file type is a block device.
     fn is_block_device(&self) -> bool;
@@ -477,8 +457,6 @@ fn is_socket_stream(&self) -> bool {
 }
 
 /// WASI-specific extension methods for [`fs::DirEntry`].
-///
-/// [`fs::DirEntry`]: ../../../../std/fs/struct.DirEntry.html
 pub trait DirEntryExt {
     /// Returns the underlying `d_ino` field of the `dirent_t`
     fn ino(&self) -> u64;