Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 595c624

Browse files
authoredMar 14, 2025
Rollup merge of #136230 - clarfonthey:net-memory-layout-assumptions, r=cuviper
Reword incorrect documentation about SocketAddr having varying layout This has no longer been the case since these types were moved to `core`. The note on portability remains, but it is reworded to not imply that the size varies by target.
2 parents c62707e + ffa86bf commit 595c624

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed
 

‎library/core/src/net/socket_addr.rs

+21-11
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr};
88
/// as possibly some version-dependent additional information. See [`SocketAddrV4`]'s and
99
/// [`SocketAddrV6`]'s respective documentation for more details.
1010
///
11-
/// The size of a `SocketAddr` instance may vary depending on the target operating
12-
/// system.
13-
///
1411
/// [IP address]: IpAddr
1512
///
13+
/// # Portability
14+
///
15+
/// `SocketAddr` is intended to be a portable representation of socket addresses and is likely not
16+
/// the same as the internal socket address type used by the target operating system's API. Like all
17+
/// `repr(Rust)` structs, however, its exact layout remains undefined and should not be relied upon
18+
/// between builds.
19+
///
1620
/// # Examples
1721
///
1822
/// ```
@@ -42,13 +46,16 @@ pub enum SocketAddr {
4246
///
4347
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses.
4448
///
45-
/// The size of a `SocketAddrV4` struct may vary depending on the target operating
46-
/// system. Do not assume that this type has the same memory layout as the underlying
47-
/// system representation.
48-
///
4949
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
5050
/// [`IPv4` address]: Ipv4Addr
5151
///
52+
/// # Portability
53+
///
54+
/// `SocketAddrV4` is intended to be a portable representation of socket addresses and is likely not
55+
/// the same as the internal socket address type used by the target operating system's API. Like all
56+
/// `repr(Rust)` structs, however, its exact layout remains undefined and should not be relied upon
57+
/// between builds.
58+
///
5259
/// # Textual representation
5360
///
5461
/// `SocketAddrV4` provides a [`FromStr`](crate::str::FromStr) implementation.
@@ -84,13 +91,16 @@ pub struct SocketAddrV4 {
8491
///
8592
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses.
8693
///
87-
/// The size of a `SocketAddrV6` struct may vary depending on the target operating
88-
/// system. Do not assume that this type has the same memory layout as the underlying
89-
/// system representation.
90-
///
9194
/// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3
9295
/// [`IPv6` address]: Ipv6Addr
9396
///
97+
/// # Portability
98+
///
99+
/// `SocketAddrV6` is intended to be a portable representation of socket addresses and is likely not
100+
/// the same as the internal socket address type used by the target operating system's API. Like all
101+
/// `repr(Rust)` structs, however, its exact layout remains undefined and should not be relied upon
102+
/// between builds.
103+
///
94104
/// # Textual representation
95105
///
96106
/// `SocketAddrV6` provides a [`FromStr`](crate::str::FromStr) implementation,

0 commit comments

Comments
 (0)
Failed to load comments.