-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more syscall doc aliases to std docs #113891
base: master
Are you sure you want to change the base?
Add more syscall doc aliases to std docs #113891
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR breaks the doc alias policy in quite a few places, which I’ve now highlighted. I left them in the PR itself because I wasn’t sure what the best course of action was. (In my opinion, after making this PR, the policy is overly restrictive).
@@ -1937,6 +1943,7 @@ pub fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> { | |||
/// Ok(()) | |||
/// } | |||
/// ``` | |||
#[doc(alias = "lstat", alias = "GetFileAttributes", alias = "GetFileAttributesEx")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Windows functions here break the doc alias policy, since GetFileAttributes
is now mapped to multiple functions. We now have to weigh up the inconsistency of breaking the doc alias policy versus the inconsistency of offering the alises only on Unix.
@@ -2038,6 +2046,10 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> | |||
/// Ok(()) | |||
/// } | |||
/// ``` | |||
#[doc(alias = "cp")] | |||
#[doc(alias = "copy_file_range")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another instance of breaking the doc alias policy, where io::copy
is also aliased to copy_file_range
. I’m not sure which should win out here, because when a user wants to call copy_file_range
they could plausibly end up calling either of these two functions.
@@ -2276,6 +2289,7 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { | |||
/// Ok(()) | |||
/// } | |||
/// ``` | |||
#[doc(alias = "mkdir", alias = "CreateDirectory")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another instance where we either choose to break the alias policy, or have to decide which one of create_dir
vs create_dir_all
“wins out” and gets the alias.
@@ -616,6 +617,7 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io: | |||
/// the process as an administrator. | |||
/// | |||
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links | |||
#[doc(alias = "CreateSymbolicLink", alias = "CreateSymbolicLinkW")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A case similar to the create_dir[_all]
case: Which one of these functions (symlink_file
or symlink_dir
) should win out and get to take the alias?
All of these seem fine to me, but need review and confirmation regarding the alias policy. r? libs |
A couple of thoughts:
My sense is that aliases are most helpful where the libc name and concept are somewhat obscure (e.g., popcnt) and it's not clear what the name Rust would choose is. Where the name or location of that concept in the standard library are much clearer, I think the value significantly diminishes. For example, ~all of the aliases on Instant and SystemTime proposed here feel excessive to me: if I'm looking for time, I can already get very good results with I'm not sure what the best way to get this reviewed is. @SabrinaJewson, are you still interested in pushing this forward? Perhaps we can split out the non-controversial bits and get those landed first, and then solicit more opinions from the library team on what folks think here? |
I think it could still be useful — there’s some value in not having to think, just copypasting the name of a system function you’re looking at the docs of and getting taken exactly to its Rust wrapper. After all, isn’t that what the existing I’m still interested in pushing this forward. The speed of this isn’t important to me, and I’m also not certain which parts are non-controversial, so I don’t immediately know how I would split this. Mainly, I observed there was a steady stream of PRs adding specific doc aliases at random — this PR was made to bring everything in line at once. |
Let's do this:
Hopefully that gives us an incremental path forward, anything not covered we can revisit once that's all squared away. Thanks! |
@@ -2359,6 +2373,7 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { | |||
/// Ok(()) | |||
/// } | |||
/// ``` | |||
#[doc(alias = "rm")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(seems like I forgot this one, it also breaks the policy).
8d9f39e
to
fbc92f0
Compare
PRs have been filed. This PR is now blocked on rust-lang/std-dev-guide#64 |
…, r=Mark-Simulacrum Add uncontroversial syscall doc aliases to std docs This PR contains the parts of rust-lang#113891 that don’t break the doc alias policy. r? `@Mark-Simulacrum`
Rollup merge of rust-lang#121266 - SabrinaJewson:easy-syscall-aliases, r=Mark-Simulacrum Add uncontroversial syscall doc aliases to std docs This PR contains the parts of rust-lang#113891 that don’t break the doc alias policy. r? `@Mark-Simulacrum`
Some of these are quite trivial but we should optimize for the user not having to think about it.
Blocked on rust-lang/std-dev-guide#64