Skip to content

Commit 5c03d0f

Browse files
authored
Rollup merge of #121266 - SabrinaJewson:easy-syscall-aliases, r=Mark-Simulacrum
Add uncontroversial syscall doc aliases to std docs This PR contains the parts of #113891 that don’t break the doc alias policy. r? `@Mark-Simulacrum`
2 parents d35c4f9 + 6be93cc commit 5c03d0f

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

library/std/src/env.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn current_dir() -> io::Result<PathBuf> {
7878
/// assert!(env::set_current_dir(&root).is_ok());
7979
/// println!("Successfully changed working directory to {}!", root.display());
8080
/// ```
81-
#[doc(alias = "chdir")]
81+
#[doc(alias = "chdir", alias = "SetCurrentDirectory", alias = "SetCurrentDirectoryW")]
8282
#[stable(feature = "env", since = "1.0.0")]
8383
pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
8484
os_imp::chdir(path.as_ref())
@@ -655,6 +655,7 @@ pub fn home_dir() -> Option<PathBuf> {
655655
/// }
656656
/// ```
657657
#[must_use]
658+
#[doc(alias = "GetTempPath", alias = "GetTempPath2")]
658659
#[stable(feature = "env", since = "1.0.0")]
659660
pub fn temp_dir() -> PathBuf {
660661
os_imp::temp_dir()

library/std/src/fs.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ impl File {
656656
///
657657
/// Note that this method alters the permissions of the underlying file,
658658
/// even though it takes `&self` rather than `&mut self`.
659+
#[doc(alias = "fchmod", alias = "SetFileInformationByHandle")]
659660
#[stable(feature = "set_permissions_atomic", since = "1.16.0")]
660661
pub fn set_permissions(&self, perm: Permissions) -> io::Result<()> {
661662
self.inner.set_permissions(perm.0)
@@ -1314,6 +1315,7 @@ impl Metadata {
13141315
/// Ok(())
13151316
/// }
13161317
/// ```
1318+
#[doc(alias = "mtime", alias = "ftLastWriteTime")]
13171319
#[stable(feature = "fs_time", since = "1.10.0")]
13181320
pub fn modified(&self) -> io::Result<SystemTime> {
13191321
self.0.modified().map(FromInner::from_inner)
@@ -1349,6 +1351,7 @@ impl Metadata {
13491351
/// Ok(())
13501352
/// }
13511353
/// ```
1354+
#[doc(alias = "atime", alias = "ftLastAccessTime")]
13521355
#[stable(feature = "fs_time", since = "1.10.0")]
13531356
pub fn accessed(&self) -> io::Result<SystemTime> {
13541357
self.0.accessed().map(FromInner::from_inner)
@@ -1381,6 +1384,7 @@ impl Metadata {
13811384
/// Ok(())
13821385
/// }
13831386
/// ```
1387+
#[doc(alias = "btime", alias = "birthtime", alias = "ftCreationTime")]
13841388
#[stable(feature = "fs_time", since = "1.10.0")]
13851389
pub fn created(&self) -> io::Result<SystemTime> {
13861390
self.0.created().map(FromInner::from_inner)
@@ -1879,6 +1883,7 @@ impl AsInner<fs_imp::DirEntry> for DirEntry {
18791883
/// Ok(())
18801884
/// }
18811885
/// ```
1886+
#[doc(alias = "rm", alias = "unlink", alias = "DeleteFile")]
18821887
#[stable(feature = "rust1", since = "1.0.0")]
18831888
pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
18841889
fs_imp::unlink(path.as_ref())
@@ -1917,6 +1922,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> io::Result<()> {
19171922
/// Ok(())
19181923
/// }
19191924
/// ```
1925+
#[doc(alias = "stat")]
19201926
#[stable(feature = "rust1", since = "1.0.0")]
19211927
pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
19221928
fs_imp::stat(path.as_ref()).map(Metadata)
@@ -1951,6 +1957,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
19511957
/// Ok(())
19521958
/// }
19531959
/// ```
1960+
#[doc(alias = "lstat")]
19541961
#[stable(feature = "symlink_metadata", since = "1.1.0")]
19551962
pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
19561963
fs_imp::lstat(path.as_ref()).map(Metadata)
@@ -1994,6 +2001,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
19942001
/// Ok(())
19952002
/// }
19962003
/// ```
2004+
#[doc(alias = "mv", alias = "MoveFile", alias = "MoveFileEx")]
19972005
#[stable(feature = "rust1", since = "1.0.0")]
19982006
pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> {
19992007
fs_imp::rename(from.as_ref(), to.as_ref())
@@ -2052,6 +2060,9 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
20522060
/// Ok(())
20532061
/// }
20542062
/// ```
2063+
#[doc(alias = "cp")]
2064+
#[doc(alias = "CopyFile", alias = "CopyFileEx")]
2065+
#[doc(alias = "fclonefileat", alias = "fcopyfile")]
20552066
#[stable(feature = "rust1", since = "1.0.0")]
20562067
pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
20572068
fs_imp::copy(from.as_ref(), to.as_ref())
@@ -2096,6 +2107,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
20962107
/// Ok(())
20972108
/// }
20982109
/// ```
2110+
#[doc(alias = "CreateHardLink", alias = "linkat")]
20992111
#[stable(feature = "rust1", since = "1.0.0")]
21002112
pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
21012113
fs_imp::link(original.as_ref(), link.as_ref())
@@ -2245,7 +2257,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
22452257
/// Ok(())
22462258
/// }
22472259
/// ```
2248-
#[doc(alias = "mkdir")]
2260+
#[doc(alias = "mkdir", alias = "CreateDirectory")]
22492261
#[stable(feature = "rust1", since = "1.0.0")]
22502262
#[cfg_attr(not(test), rustc_diagnostic_item = "fs_create_dir")]
22512263
pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
@@ -2326,7 +2338,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
23262338
/// Ok(())
23272339
/// }
23282340
/// ```
2329-
#[doc(alias = "rmdir")]
2341+
#[doc(alias = "rmdir", alias = "RemoveDirectory")]
23302342
#[stable(feature = "rust1", since = "1.0.0")]
23312343
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
23322344
fs_imp::rmdir(path.as_ref())
@@ -2449,6 +2461,7 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
24492461
/// Ok(())
24502462
/// }
24512463
/// ```
2464+
#[doc(alias = "ls", alias = "opendir", alias = "FindFirstFile", alias = "FindNextFile")]
24522465
#[stable(feature = "rust1", since = "1.0.0")]
24532466
pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
24542467
fs_imp::readdir(path.as_ref()).map(ReadDir)
@@ -2484,6 +2497,7 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
24842497
/// Ok(())
24852498
/// }
24862499
/// ```
2500+
#[doc(alias = "chmod", alias = "SetFileAttributes")]
24872501
#[stable(feature = "set_permissions", since = "1.1.0")]
24882502
pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result<()> {
24892503
fs_imp::set_perm(path.as_ref(), perm.0)

library/std/src/os/wasi/fs.rs

+14
Original file line numberDiff line numberDiff line change
@@ -173,51 +173,61 @@ pub trait FileExt {
173173
///
174174
/// This corresponds to the `fd_tell` syscall and is similar to
175175
/// `seek` where you offset 0 bytes from the current position.
176+
#[doc(alias = "fd_tell")]
176177
fn tell(&self) -> io::Result<u64>;
177178

178179
/// Adjust the flags associated with this file.
179180
///
180181
/// This corresponds to the `fd_fdstat_set_flags` syscall.
182+
#[doc(alias = "fd_fdstat_set_flags")]
181183
fn fdstat_set_flags(&self, flags: u16) -> io::Result<()>;
182184

183185
/// Adjust the rights associated with this file.
184186
///
185187
/// This corresponds to the `fd_fdstat_set_rights` syscall.
188+
#[doc(alias = "fd_fdstat_set_rights")]
186189
fn fdstat_set_rights(&self, rights: u64, inheriting: u64) -> io::Result<()>;
187190

188191
/// Provide file advisory information on a file descriptor.
189192
///
190193
/// This corresponds to the `fd_advise` syscall.
194+
#[doc(alias = "fd_advise")]
191195
fn advise(&self, offset: u64, len: u64, advice: u8) -> io::Result<()>;
192196

193197
/// Force the allocation of space in a file.
194198
///
195199
/// This corresponds to the `fd_allocate` syscall.
200+
#[doc(alias = "fd_allocate")]
196201
fn allocate(&self, offset: u64, len: u64) -> io::Result<()>;
197202

198203
/// Create a directory.
199204
///
200205
/// This corresponds to the `path_create_directory` syscall.
206+
#[doc(alias = "path_create_directory")]
201207
fn create_directory<P: AsRef<Path>>(&self, dir: P) -> io::Result<()>;
202208

203209
/// Read the contents of a symbolic link.
204210
///
205211
/// This corresponds to the `path_readlink` syscall.
212+
#[doc(alias = "path_readlink")]
206213
fn read_link<P: AsRef<Path>>(&self, path: P) -> io::Result<PathBuf>;
207214

208215
/// Return the attributes of a file or directory.
209216
///
210217
/// This corresponds to the `path_filestat_get` syscall.
218+
#[doc(alias = "path_filestat_get")]
211219
fn metadata_at<P: AsRef<Path>>(&self, lookup_flags: u32, path: P) -> io::Result<Metadata>;
212220

213221
/// Unlink a file.
214222
///
215223
/// This corresponds to the `path_unlink_file` syscall.
224+
#[doc(alias = "path_unlink_file")]
216225
fn remove_file<P: AsRef<Path>>(&self, path: P) -> io::Result<()>;
217226

218227
/// Remove a directory.
219228
///
220229
/// This corresponds to the `path_remove_directory` syscall.
230+
#[doc(alias = "path_remove_directory")]
221231
fn remove_directory<P: AsRef<Path>>(&self, path: P) -> io::Result<()>;
222232
}
223233

@@ -359,6 +369,7 @@ pub trait OpenOptionsExt {
359369
/// Open a file or directory.
360370
///
361371
/// This corresponds to the `path_open` syscall.
372+
#[doc(alias = "path_open")]
362373
fn open_at<P: AsRef<Path>>(&self, file: &File, path: P) -> io::Result<File>;
363374
}
364375

@@ -500,6 +511,7 @@ impl DirEntryExt for fs::DirEntry {
500511
/// Create a hard link.
501512
///
502513
/// This corresponds to the `path_link` syscall.
514+
#[doc(alias = "path_link")]
503515
pub fn link<P: AsRef<Path>, U: AsRef<Path>>(
504516
old_fd: &File,
505517
old_flags: u32,
@@ -518,6 +530,7 @@ pub fn link<P: AsRef<Path>, U: AsRef<Path>>(
518530
/// Rename a file or directory.
519531
///
520532
/// This corresponds to the `path_rename` syscall.
533+
#[doc(alias = "path_rename")]
521534
pub fn rename<P: AsRef<Path>, U: AsRef<Path>>(
522535
old_fd: &File,
523536
old_path: P,
@@ -534,6 +547,7 @@ pub fn rename<P: AsRef<Path>, U: AsRef<Path>>(
534547
/// Create a symbolic link.
535548
///
536549
/// This corresponds to the `path_symlink` syscall.
550+
#[doc(alias = "path_symlink")]
537551
pub fn symlink<P: AsRef<Path>, U: AsRef<Path>>(
538552
old_path: P,
539553
fd: &File,

0 commit comments

Comments
 (0)