Skip to content
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

Merged
merged 4 commits into from
Mar 26, 2018

Conversation

Phlosioneer
Copy link
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
Collaborator

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-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 11, 2018
@sfackler
Copy link
Member

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

@Phlosioneer
Copy link
Contributor Author

I pushed a new commit; re-review?

@Phlosioneer
Copy link
Contributor Author

Phlosioneer commented Mar 16, 2018

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

Copy link
Contributor

@KodrAus KodrAus left a 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.

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

@@ -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
Copy link
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
Contributor Author

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
Contributor Author

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

Copy link
Contributor

@KodrAus KodrAus left a 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.

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

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

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

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

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

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

@@ -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
Copy link
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
Contributor Author

Updated, @KodrAus

@KodrAus
Copy link
Contributor

KodrAus commented Mar 25, 2018

Thanks @Phlosioneer!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 25, 2018

📌 Commit efd0442 has been approved by KodrAus

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

closes rust-lang#43601.
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.

closes rust-lang#43601.
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:master Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: 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