-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Move std::net::IpAddr
types into core::net
.
#2832
Conversation
565c02d
to
c473501
Compare
Given that most IP based networking is done over UDP/TCP, even for IoT devices, I think it would make sense to move the |
…mulacrum Remove boxed closures in address parser. Simplify address parser by removing unnecessary boxed closures. Also relevant for rust-lang/rfcs#2832.
This seems entirely reasonable to me. One thing the RFC should discuss, though: will all platforms that use a given target have the same interpretation of the type? Is the inner storage expected to be in network-endian byte order or native-endian byte order? |
The inner octets should always be stored in network/big-endian order. The current |
I agree that it makes sense to move the Now there are two options on how to represent them: The Rust Way: pub struct SocketAddrV4 {
ip: Ipv4Addr,
port: u16,
}
pub struct SocketAddrV6 {
ip: Ipv6Addr,
port: u16,
flowinfo: u32,
scope_id: u32,
} This makes these types as portable as possible but we have to construct the corresponding The C Way: pub struct SocketAddrV4 {
__padding: [u8; 2],
port: u16,
ip: Ipv4Addr,
__zero: [u8; 8]
}
pub struct SocketAddrV6 {
__padding: [u8; 2],
port: u16,
flowinfo: u32,
ip: Ipv6Addr,
scope_id: u32,
} According to RFC 2553, len: u8,
family: u8, or just family: u16, and Note that in the current implementation we never set This way we can cast directly to the
|
@reitermarkus If the socketaddr types aren't identical across platforms, I don't think we want them in core. |
They are definitely identical with the pure Rust representation. Also Now for the C representation of RFC 2553 also states the following:
So even if there were platforms actually using RFC 2553 also mentions:
That means that That means we will have to provide a shim for Haiku, since it will try to zero a This way |
Small nitpick, both the title of the PR and the commit message say: This would be a funny module name, given that .NET Core is the name of the .NET compiler. But I think it's both a bit too confusing, since std::.net does not exist, and it's actually a typo because the rfc itself only mentions core::net So I suggest changing it to core::net in the PR and commit title. |
std::net
types into core:.net
.std::net
types into core::net
.
👍 the Harder questions like (P.S. The title of this RFC surprised me -- it makes it seem like everything, not a subset.) |
Well, the idea was to move most types, but I think scoping this RFC to just IP address types might be best to get things moving. |
std::net
types into core::net
.std::net::IpAddr
types into core::net
.
c3a4a4f
to
a36fb49
Compare
a36fb49
to
49a923b
Compare
Any more concerns or suggestions? |
it would be super great to have however, without the |
Please stop. I am not on the libs team, I don't know why you want my review here. If someone undoes an action you've taken you should at most ask why, not immediately do it again. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
Ideally |
What's the issue with having unused code in |
So this is actually going to happen with the current EDIT: I added some test suggestions- rust-lang/rust#104265 (comment) - I think RFC should still cover the impact and/or at least the intent here properly what would or should and should not happen as currently it is vague to this respect. |
@pinkforest could you explain why you think codesize of the final linked binary would change? If you don't use types they should be stripped out by the linker when you build a binary. |
Problem is this RFC is vague and it is left to assumption that this lto happen now and in the future. RFC should state the goals more clear what would and should not happen considering this is now / further making the core as standard library -like without taking into account carefully between different types of targets. Ideally there should be statements which then can be turned into tests to alleviate these concerns. It's like trying to deal with These kind of changes need guarantees and clarity on assumptions not just having to rely on current assumptions what will happen in the future - also considering there used to be a lot of target specific stuff. Every statement in any RFC should be something that can be tested across all the targets and hosts that doesn't rely on people relying on assumptions. Also someone should visit the definition what core is and means exactly. It is becoming very vague ? |
text/0000-core-net-types.md
Outdated
# Drawbacks | ||
[drawbacks]: #drawbacks | ||
|
||
Moving the `std::net` types to `core::net` makes the core library less *minimal*. |
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.
Moving the `std::net` types to `core::net` makes the core library less *minimal*. | |
Moving the `std::net` types to `core::net` makes the core library less *seemingly minimal*. | |
However optimisations relied from the compiler means the dead code types must never be included | |
in the built binary when not used. |
I think this could be best clarified here what this "minimal" means ?
Since the code is optimised away on cases where it is not used as #2832 (comment) - This provides testing coverage for rust-lang/rust#104265 (comment)
@pinkforest dead code elimination is one of the most basic optimizations. Requiring the RFC to state that it is required is like requiring that RFC states that 1 + 1 == 2. If you have it enabled (with LTO and such) you have nothing to worry about. If you make a space-limited project why wouldn't this be the first thing you enable? There's ton of other code it can eliminate as well, not just these types! |
IMO when we want to add something new into the standard library then T-libs-api should prudently evaluate the necessity first, but moving something already in |
You don't even need to enable LTO: the linker will simply not include any functions that are not referenced in the binary. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
I think the PR that implements this RFC is ready. And the FCP completed two weeks ago. Can we get this merged?
I was not able to do this because of the url to the documentation changing. But from my testing it seems enough to just make the module |
FCP completed; merging. Tracking issue: rust-lang/rust#108443 Implementation in progress: rust-lang/rust#104265 |
…riplett Move IpAddr, SocketAddr and V4+V6 related types to `core` Implements RFC rust-lang/rfcs#2832. The RFC has completed FCP with disposition merge, but is not yet merged. Moves IP types to `core` as specified in the RFC. The full list of moved types is: `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, `SocketAddrV6`, `Ipv6MulticastScope` and `AddrParseError`. Doing this move was one of the main driving arguments behind rust-lang#78802.
…riplett Move IpAddr, SocketAddr and V4+V6 related types to `core` Implements RFC rust-lang/rfcs#2832. The RFC has completed FCP with disposition merge, but is not yet merged. Moves IP types to `core` as specified in the RFC. The full list of moved types is: `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, `SocketAddrV6`, `Ipv6MulticastScope` and `AddrParseError`. Doing this move was one of the main driving arguments behind rust-lang#78802.
…riplett Move IpAddr, SocketAddr and V4+V6 related types to `core` Implements RFC rust-lang/rfcs#2832. The RFC has completed FCP with disposition merge, but is not yet merged. Moves IP types to `core` as specified in the RFC. The full list of moved types is: `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, `SocketAddrV6`, `Ipv6MulticastScope` and `AddrParseError`. Doing this move was one of the main driving arguments behind rust-lang#78802.
Move IpAddr, SocketAddr and V4+V6 related types to `core` Implements RFC rust-lang/rfcs#2832. The RFC has completed FCP with disposition merge, but is not yet merged. Moves IP types to `core` as specified in the RFC. The full list of moved types is: `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, `SocketAddrV6`, `Ipv6MulticastScope` and `AddrParseError`. Doing this move was one of the main driving arguments behind #78802.
Stabilize ip_in_core feature Finally the last stage of rust-lang/rfcs#2832. Since the FCP was [just completed with disposition *merge*](rust-lang#108443 (comment)), I create the stabilization PR for the `ip_in_core` feature. Allowing usage of `core::net` on stable Rust. The error type `core::net::AddrParseError` itself becomes stable with this PR. However, `core::error::Error` is still unstable, so the `Error` impl for this type is not available on stable rust. Simply because `error_in_core` is not stable yet, but that should be fine!
Stabilize ip_in_core feature Finally the last stage of rust-lang/rfcs#2832. Since the FCP was [just completed with disposition *merge*](rust-lang#108443 (comment)), I create the stabilization PR for the `ip_in_core` feature. Allowing usage of `core::net` on stable Rust. The error type `core::net::AddrParseError` itself becomes stable with this PR. However, `core::error::Error` is still unstable, so the `Error` impl for this type is not available on stable rust. Simply because `error_in_core` is not stable yet, but that should be fine!
Make the
IpAddr
,Ipv4Addr
,Ipv6Addr
,SocketAddr
,SocketAddrV4
,SocketAddrV6
,Ipv6MulticastScope
andAddrParseError
types available inno_std
contexts by moving them into a
core::net
module.Rendered
Implementation: rust-lang/rust#104265