-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Document when types have OS-dependent sizes #48932
Document when types have OS-dependent sizes #48932
Conversation
As per issue rust-lang#43601, types that can change size depending on the target operating system should say so in their documentation. I used this template when adding doc comments: The size of a(n) <name> struct may vary depending on the target operating system, and may change between Rust releases. For enums, I used "instance" instead of "struct".
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @KodrAus (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There are like 3 types that can't change size between releases so I wouldn't include that bit. |
I pushed a new commit; re-review? |
@KodrAus re-review? This is just a small documentation addition... If you're busy, we can reassign it to someone else, I'd just like to make progress of some kind. |
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.
Thanks @Phlosioneer! Just left some small nitpicks.
src/libstd/net/addr.rs
Outdated
@@ -28,6 +28,9 @@ use slice; | |||
/// as possibly some version-dependent additional information. See [`SocketAddrV4`]'s and | |||
/// [`SocketAddrV6`]'s respective documentation for more details. | |||
/// | |||
/// The size of a SocketAddr instance may vary depending on the target operating |
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.
nit: Let's wrap SocketAddr
in backticks here.
src/libstd/io/stdio.rs
Outdated
@@ -30,18 +30,27 @@ thread_local! { | |||
/// | |||
/// This handle is not synchronized or buffered in any fashion. Constructed via | |||
/// the `std::io::stdio::stdin_raw` function. | |||
/// | |||
/// The size of a StdinRaw struct may vary depending on the target operating |
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.
Since these types aren't publicly exported do you think we need to mention their size variance?
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.
Oh, if it's not public then yeah, that can be omitted.
@KodrAus Addressed your concerns, next time you get a chance to review. |
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.
Thanks @Phlosioneer! Just a few more backticks to add, then I think this will be good to go.
src/libstd/net/addr.rs
Outdated
@@ -61,6 +64,9 @@ pub enum SocketAddr { | |||
/// | |||
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses. | |||
/// | |||
/// The size of a SocketAddrV4 struct may vary depending on the target operating |
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.
Let's put some backticks on SocketAddrV4
here too.
src/libstd/net/addr.rs
Outdated
@@ -88,6 +94,9 @@ pub struct SocketAddrV4 { inner: c::sockaddr_in } | |||
/// | |||
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses. | |||
/// | |||
/// The size of a SocketAddrV6 struct may vary depending on the target operating |
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.
Let's put some backticks on SocketAddrV6
here too.
src/libstd/net/ip.rs
Outdated
@@ -26,6 +26,9 @@ use sys_common::{AsInner, FromInner}; | |||
/// This enum can contain either an [`Ipv4Addr`] or an [`Ipv6Addr`], see their | |||
/// respective documentation for more details. | |||
/// | |||
/// The size of an IpAddr instance may vary depending on the target operating |
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.
Let's put some backticks on IpAddr
here too.
src/libstd/net/ip.rs
Outdated
@@ -61,6 +64,9 @@ pub enum IpAddr { | |||
/// | |||
/// See [`IpAddr`] for a type encompassing both IPv4 and IPv6 addresses. | |||
/// | |||
/// The size of an Ipv4Addr struct may vary depending on the target operating |
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.
Let's put some backticks on Ipv4Addr
here too.
src/libstd/net/ip.rs
Outdated
@@ -93,6 +99,9 @@ pub struct Ipv4Addr { | |||
/// | |||
/// See [`IpAddr`] for a type encompassing both IPv4 and IPv6 addresses. | |||
/// | |||
/// The size of an Ipv6Addr struct may vary depending on the target operating |
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.
Let's put some backticks on Ipv6Addr
here too.
src/libstd/time.rs
Outdated
@@ -49,6 +49,9 @@ pub use core::time::Duration; | |||
/// allows measuring the duration between two instants (or comparing two | |||
/// instants). | |||
/// | |||
/// The size of an Instant struct may vary depending on the target operating |
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.
Let's put some backticks on Instant
here too.
src/libstd/time.rs
Outdated
@@ -88,6 +91,9 @@ pub struct Instant(time::Instant); | |||
/// fixed point in time, a `SystemTime` can be converted to a human-readable time, | |||
/// or perhaps some other string representation. | |||
/// | |||
/// The size of a SystemTime struct may vary depending on the target operating |
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.
Let's put some backticks on SystemTime
here too.
Updated, @KodrAus |
Thanks @Phlosioneer! @bors r+ rollup |
📌 Commit efd0442 has been approved by |
…ize, r=KodrAus Document when types have OS-dependent sizes As per issue rust-lang#43601, types that can change size depending on the target operating system should say so in their documentation. I used this template when adding doc comments: ``` The size of a(n) <name> struct may vary depending on the target operating system, and may change between Rust releases. ``` For enums, I used "instance" instead of "struct". I added documentation to these types: ``` - std::time::Instant (contains sys::time::Instant) - std::time::SystemTime (contains sys::time::SystemTime) - std::io::StdinRaw (contains sys::stdio::Stdin) - std::io::StdoutRaw (contains sys::stdio::Stdout) - std::io::Stderr (contains sys::stdio::Stderr) - std::net::addr::SocketAddrV4 (contains sys::net::netc::sockaddr_in) - std::net::addr::SocketAddrV6 (contains sys::net::netc::sockaddr_in6) - std::net::addr::SocketAddr (contains std::net::addr::SocketAddrV4 and SocketAddrV6) - std::net::ip::Ipv4Addr (contains sys::net::netc::in_addr) - std::net::ip::Ipv6Addr (contains sys::net::netc::in6_addr) - std::net::ip::IpAddr (contains std::net::ip::Ipv4Addr and Ipv6Addr) ``` I also found that these types varied in size; however, I don't think they need documentation, as it's already fairly obvious that they change based on different OS's: ``` - std::fs::DirBuilder (contains sys::fs::DirBuilder) - std::fs::FileType (contains sys::fs::FileType) - std::fs::Permissions (contains sys::fs::FilePermissions) - std::fs::OpenOptions (contains sys::fs::OpenOptions) - std::fs::DirEntry (contains sys::fs::DirEntry) - std::fs::ReadDir (contains sys::fs::ReadDir) - std::fs::Metadata (contains sys::fs::FileAttr) - std::fs::File (contains sys::fs::File) - std::process::Child (contains sys::process::Process) - std::process::ChildStdin (contains sys::process::AnonPipe) - std::process::ChildStdout (contains sys::process::AnonPipe) - std::process::ChildStderr (contains sys::process::AnonPipe) - std::process::Command (contains sys::process::Command) - std::process::Stdio (contains sys::process::Stdio) - std::process::ExitStatus (contains sys::process::ExitStatus) - std::process::Output (contains std::process::ExitStatus) - std::sys_common::condvar::Condvar (contains sys::condvar::Condvar) - std::sys_common::mutex::Mutex (contains sys::mutex::Mutex) - std::sys_common::net::LookupHost (contains sys::net::netc::addrinfo) - std::sys_common::net::TcpStream (contains sys::net::Socket) - std::sys_common::net::TcpListener (contains sys::net::Socket) - std::sys_common::net::UdpSocket (contains sys::net::Socket) - std::sys_common::remutex::ReentrantMutex (contains sys::mutex::ReentrantMutex) - std::sys_common::rwlock::RWLock (contains sys::rwlock::RWLock) - std::sys_common::thread_local::Key (contains sys::thread_local::Key) ``` Maybe we should just put a comment about the size of structs in the module-level docs for `fs`, `process`, and `sys_common`? If anyone can think of other types that can change size, comment below. I'm also open to changing the wording. closes rust-lang#43601.
…ize, r=KodrAus Document when types have OS-dependent sizes As per issue rust-lang#43601, types that can change size depending on the target operating system should say so in their documentation. I used this template when adding doc comments: ``` The size of a(n) <name> struct may vary depending on the target operating system, and may change between Rust releases. ``` For enums, I used "instance" instead of "struct". I added documentation to these types: ``` - std::time::Instant (contains sys::time::Instant) - std::time::SystemTime (contains sys::time::SystemTime) - std::io::StdinRaw (contains sys::stdio::Stdin) - std::io::StdoutRaw (contains sys::stdio::Stdout) - std::io::Stderr (contains sys::stdio::Stderr) - std::net::addr::SocketAddrV4 (contains sys::net::netc::sockaddr_in) - std::net::addr::SocketAddrV6 (contains sys::net::netc::sockaddr_in6) - std::net::addr::SocketAddr (contains std::net::addr::SocketAddrV4 and SocketAddrV6) - std::net::ip::Ipv4Addr (contains sys::net::netc::in_addr) - std::net::ip::Ipv6Addr (contains sys::net::netc::in6_addr) - std::net::ip::IpAddr (contains std::net::ip::Ipv4Addr and Ipv6Addr) ``` I also found that these types varied in size; however, I don't think they need documentation, as it's already fairly obvious that they change based on different OS's: ``` - std::fs::DirBuilder (contains sys::fs::DirBuilder) - std::fs::FileType (contains sys::fs::FileType) - std::fs::Permissions (contains sys::fs::FilePermissions) - std::fs::OpenOptions (contains sys::fs::OpenOptions) - std::fs::DirEntry (contains sys::fs::DirEntry) - std::fs::ReadDir (contains sys::fs::ReadDir) - std::fs::Metadata (contains sys::fs::FileAttr) - std::fs::File (contains sys::fs::File) - std::process::Child (contains sys::process::Process) - std::process::ChildStdin (contains sys::process::AnonPipe) - std::process::ChildStdout (contains sys::process::AnonPipe) - std::process::ChildStderr (contains sys::process::AnonPipe) - std::process::Command (contains sys::process::Command) - std::process::Stdio (contains sys::process::Stdio) - std::process::ExitStatus (contains sys::process::ExitStatus) - std::process::Output (contains std::process::ExitStatus) - std::sys_common::condvar::Condvar (contains sys::condvar::Condvar) - std::sys_common::mutex::Mutex (contains sys::mutex::Mutex) - std::sys_common::net::LookupHost (contains sys::net::netc::addrinfo) - std::sys_common::net::TcpStream (contains sys::net::Socket) - std::sys_common::net::TcpListener (contains sys::net::Socket) - std::sys_common::net::UdpSocket (contains sys::net::Socket) - std::sys_common::remutex::ReentrantMutex (contains sys::mutex::ReentrantMutex) - std::sys_common::rwlock::RWLock (contains sys::rwlock::RWLock) - std::sys_common::thread_local::Key (contains sys::thread_local::Key) ``` Maybe we should just put a comment about the size of structs in the module-level docs for `fs`, `process`, and `sys_common`? If anyone can think of other types that can change size, comment below. I'm also open to changing the wording. closes rust-lang#43601.
As per issue #43601, types that can change size depending on the
target operating system should say so in their documentation.
I used this template when adding doc comments:
For enums, I used "instance" instead of "struct".
I added documentation to these types:
I also found that these types varied in size; however, I don't think they need documentation, as it's already fairly obvious that they change based on different OS's:
Maybe we should just put a comment about the size of structs in the module-level docs for
fs
,process
, andsys_common
?If anyone can think of other types that can change size, comment below. I'm also open to changing the wording.
closes #43601.