-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Constify std::net::IpAddr, Ipv4Addr, and Ipv6Addr #76205
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Due to recent stabilizations of const integer arithmetic and const control flow, all methods of types
std::net::IpAddr,Ipv4Addr, andIpv6Addrcan be made const. This issue provides an overview of all methods and steps that need to be taken:Ipv4AddrMethods already stable const:
newis_unspecifiedMethods unstable const by PR#76142 (
const_ipv4):octetsis_loopbackis_privateis_link_localis_shared(unstable)is_ietf_protocol_assignment(unstable)is_benchmarking(unstable)is_multicastis_documentationis_global(unstable)is_reserved(unstable)is_broadcastto_ipv6_compatible(deprecated?)to_ipv6_mappedNone of these methods depends on an unstable feature, and could all thus be made stable const.
Ipv6AddrMethods already stable const:
new(uses#[allow_internal_unstable(const_fn_transmute)])octetsIpv6Addr::segmentshas been made unstable const in PR#76206 (const_ipv6), together with all dependent methods:segmentsis_unspecifiedis_loopbackis_global(unstable)is_unique_local(unstable)is_unicast_link_local_strict(unstable)is_documentation(unstable)multicast_scope(unstable)is_multicastto_ipv4_mapped(unstable)to_ipv4All of these methods depend on
segments, and thus upon the unstable featureconst_fn_transmute, however the transmute is only used for better code generation, the operations could be rewritten equivalently using stable const code.IpAddrThe following methods are stable const:
is_ip4is_ipv6Implemented in PR#76226.
With the relevant methods of
Ipv4AddrandIpv6Addrmade const, the following were also made unstable const in PR#76304:is_documentation(unstable)is_global(unstable)is_loopbackis_multicastis_unspecified