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

Tracking Issue for #![feature(const_socketaddr)] #82485

Closed
2 of 3 tasks
CDirkx opened this issue Feb 24, 2021 · 12 comments · Fixed by #104252
Closed
2 of 3 tasks

Tracking Issue for #![feature(const_socketaddr)] #82485

CDirkx opened this issue Feb 24, 2021 · 12 comments · Fixed by #104252
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@CDirkx
Copy link
Contributor

CDirkx commented Feb 24, 2021

Feature gate: #![feature(const_socketaddr)]

This is a tracking issue for constifying methods of std::net::SocketAddr, SocketAddrV4 and SocketAddrV6.

Public API

// std::net

impl SocketAddr {
   pub const fn new(ip: IpAddr, port: u16) -> Self;
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn is_ipv4(&self) -> bool;
    pub const fn is_ipv6(&self) -> bool;
}

impl SocketAddrV4 {
    pub const fn new(ip: Ipv4Addr, port: u16) -> Self;
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
}

impl SocketAddrV6 {
    pub const fn new(ip: Ipv6Addr, port: u16, flowinfo: u32, scope_id: u32) -> Self;
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn flowinfo(&self) -> u32;
    pub const fn scope_id(&self) -> u32;
}

Steps / History

Unresolved Questions

The methods new on all of the address could potentially also be made const, however there are two complications: getting the inner C representation of an IP address, and adding trailing zero bytes on windows. Resolved by #78802

@CDirkx CDirkx added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Feb 24, 2021
@CDirkx

This comment has been minimized.

@rustbot rustbot added the A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. label Mar 1, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 2, 2021
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`

The following methods are made unstable const under the `const_socketaddr` feature (rust-lang#82485):

```rust
// std::net

impl SocketAddr {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn is_ipv4(&self) -> bool;
    pub const fn is_ipv6(&self) -> bool;
}

impl SocketAddrV4 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
}

impl SocketAddrV6 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn flowinfo(&self) -> u32;
    pub const fn scope_id(&self) -> u32;
}
```

Note: `SocketAddrV4::ip` and `SocketAddrV6::ip` use pointer casting and depend on the unstable feature `const_raw_ptr_deref`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 3, 2021
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`

The following methods are made unstable const under the `const_socketaddr` feature (rust-lang#82485):

```rust
// std::net

impl SocketAddr {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn is_ipv4(&self) -> bool;
    pub const fn is_ipv6(&self) -> bool;
}

impl SocketAddrV4 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
}

impl SocketAddrV6 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn flowinfo(&self) -> u32;
    pub const fn scope_id(&self) -> u32;
}
```

Note: `SocketAddrV4::ip` and `SocketAddrV6::ip` use pointer casting and depend on the unstable feature `const_raw_ptr_deref`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 3, 2021
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`

The following methods are made unstable const under the `const_socketaddr` feature (rust-lang#82485):

```rust
// std::net

impl SocketAddr {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn is_ipv4(&self) -> bool;
    pub const fn is_ipv6(&self) -> bool;
}

impl SocketAddrV4 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
}

impl SocketAddrV6 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn flowinfo(&self) -> u32;
    pub const fn scope_id(&self) -> u32;
}
```

Note: `SocketAddrV4::ip` and `SocketAddrV6::ip` use pointer casting and depend on the unstable feature `const_raw_ptr_deref`
@a1ien
Copy link

a1ien commented Jan 17, 2022

What about SocketAddr::new? If we make const ip, port and and so on how we create const SocketAddr it self

PS. oh now read Unresolved Questions :) Without const new it's seams no point to make other method const

@faern
Copy link
Contributor

faern commented Jun 23, 2022

This feature gate is soon also used for the unstably constified methods SocketAddr::new, SocketAddrV4::new, SocketAddrV6::new if #78802 is merged.

@maxwase
Copy link
Contributor

maxwase commented Nov 10, 2022

I guess there are no blockers for this stabilization?

@faern
Copy link
Contributor

faern commented Nov 10, 2022

Probably not. Try submitting a stabilization PR.

EDIT: I'm on it.

@m-ou-se
Copy link
Member

m-ou-se commented Dec 14, 2022

The API overview above seems incomplete. At least SocketAddr::new() also refers to this issue. Are there any other methods missing?

@m-ou-se
Copy link
Member

m-ou-se commented Dec 14, 2022

Looks like it's only the three new methods. The issue with those has been resolved by #78802

I've updated the overview above.

@m-ou-se
Copy link
Member

m-ou-se commented Dec 14, 2022

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Dec 14, 2022

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Dec 14, 2022
@dtolnay
Copy link
Member

dtolnay commented Dec 20, 2022

I'm marking @yaahc's box because she has stepped down from T-libs-api after the point that this feature got proposed for FCP.

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Dec 20, 2022
@rfcbot
Copy link

rfcbot commented Dec 20, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Dec 20, 2022
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Dec 30, 2022
@rfcbot
Copy link

rfcbot commented Dec 30, 2022

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.

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jan 12, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jan 27, 2023
…r=JohnTitor

Stabilize the const_socketaddr feature

Stabilizes `#![feature(const_socketaddr)]`. Tracking issue: rust-lang#82485
Closes rust-lang#82485

This has been unstably const for over a year now. And the code change simplifying the constness of the `new` constructors has been in stable Rust since 1.64 (a bit over a full release cycle). I'm not aware of any blockers to this stabilization.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 28, 2023
…r=JohnTitor

Stabilize the const_socketaddr feature

Stabilizes `#![feature(const_socketaddr)]`. Tracking issue: rust-lang#82485
Closes rust-lang#82485

This has been unstably const for over a year now. And the code change simplifying the constness of the `new` constructors has been in stable Rust since 1.64 (a bit over a full release cycle). I'm not aware of any blockers to this stabilization.
@bors bors closed this as completed in 36ef4f1 Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants