Skip to content

Document when types have OS-dependent sizes - #48932

Merged
bors merged 4 commits into
rust-lang:masterfrom
Phlosioneer:43601-document-opaque-size
Mar 26, 2018
Merged

Document when types have OS-dependent sizes#48932
bors merged 4 commits into
rust-lang:masterfrom
Phlosioneer:43601-document-opaque-size

Conversation

@Phlosioneer

Copy link
Copy Markdown
Contributor

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:

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#43601.

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".
@rust-highfive

Copy link
Copy Markdown
Contributor

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.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 11, 2018
@sfackler

Copy link
Copy Markdown
Member

There are like 3 types that can't change size between releases so I wouldn't include that bit.

@Phlosioneer

Copy link
Copy Markdown
ContributorAuthor

I pushed a new commit; re-review?

@Phlosioneer

Phlosioneer commented Mar 16, 2018

Copy link
Copy Markdown
ContributorAuthor

@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.

@KodrAusKodrAus left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/net/addr.rs Outdated
/// 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

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/io/stdio.rs Outdated
/// 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

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
ContributorAuthor

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.

@Phlosioneer

Copy link
Copy Markdown
ContributorAuthor

@KodrAus Addressed your concerns, next time you get a chance to review.

@KodrAusKodrAus left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/net/addr.rs Outdated
///
/// 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

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/net/addr.rs Outdated
///
/// 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

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/net/ip.rs Outdated
/// 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

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/net/ip.rs Outdated
///
/// See [`IpAddr`] for a type encompassing both IPv4 and IPv6 addresses.
///
/// The size of an Ipv4Addr struct may vary depending on the target operating

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/net/ip.rs Outdated
///
/// See [`IpAddr`] for a type encompassing both IPv4 and IPv6 addresses.
///
/// The size of an Ipv6Addr struct may vary depending on the target operating

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/time.rs Outdated
/// allows measuring the duration between two instants (or comparing two
/// instants).
///
/// The size of an Instant struct may vary depending on the target operating

Copy link
Copy Markdown
Contributor

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.

Comment threadsrc/libstd/time.rs Outdated
/// 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

Copy link
Copy Markdown
Contributor

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.

@Phlosioneer

Copy link
Copy Markdown
ContributorAuthor

Updated, @KodrAus

@KodrAus

Copy link
Copy Markdown
Contributor

Thanks @Phlosioneer!

@bors r+ rollup

@bors

bors commented Mar 25, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit efd0442 has been approved by KodrAus

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 25, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Mar 26, 2018
…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.
closesrust-lang#43601.
@kennytmkennytm mentioned this pull request Mar 26, 2018
TimNN added a commit to TimNN/rust that referenced this pull request Mar 26, 2018
…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.
closesrust-lang#43601.
@TimNNTimNN mentioned this pull request Mar 26, 2018
bors added a commit that referenced this pull request Mar 26, 2018
Rollup of 7 pull requests
- Successful merges: #48693, #48932, #49103, #49170, #49187, #49346, #49353
- Failed merges:
@bors
bors merged commit efd0442 into rust-lang:masterMar 26, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document os-specific types in libstd may have different representations

5 participants

@Phlosioneer@rust-highfive@sfackler@KodrAus@bors