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

Constify methods of std::net::SocketAddr, SocketAddrV4 and SocketAddrV6 #82487

Merged
merged 1 commit into from
Apr 4, 2021

Conversation

CDirkx
Copy link
Contributor

@CDirkx CDirkx commented Feb 24, 2021

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

// 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

…tAddrV6`

The following methods are made unstable const under the `const_socketaddr` feature:

`SocketAddr`
 - `ip`
 - `port`
 - `is_ipv4`
 - `is_ipv6`

`SocketAddrV4`
 - `ip`
 - `port`

`SocketAddrV6`
 - `ip`
 - `port`
 - `flowinfo`
 - `scope_id`
@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 24, 2021
@CDirkx

This comment has been minimized.

@rustbot rustbot added A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 1, 2021
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2021
@joshtriplett
Copy link
Member

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Apr 1, 2021

Team member @joshtriplett 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 Apr 1, 2021
@CDirkx
Copy link
Contributor Author

CDirkx commented Apr 1, 2021

This PR makes the methods unstably const, but since there is already an FCP shall I just make them stable const? This PR also doesnt include SocketAddr::new yet.

@BurntSushi
Copy link
Member

@CDirkx @joshtriplett Hmmm, yeah I don't think we usually do an FCP for small unstable API additions.

I think we do generally want APIs to bake on unstable for a bit before stabilizing them though. Maybe we should just cancel this FCP and merge the PR for now?

@m-ou-se
Copy link
Member

m-ou-se commented Apr 2, 2021

@rfcbot cancel

@bors r+ rollup

@rfcbot
Copy link

rfcbot commented Apr 2, 2021

@m-ou-se proposal cancelled.

@bors
Copy link
Contributor

bors commented Apr 2, 2021

📌 Commit 5b84b9a has been approved by m-ou-se

@rfcbot rfcbot removed 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 Apr 2, 2021
@bors bors added disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. 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 Apr 2, 2021
@m-ou-se m-ou-se removed the disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. label Apr 2, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request 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 pull request 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`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 3, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#82487 (Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`)
 - rust-lang#83756 (rustdoc: Rename internal uses of `spotlight`)
 - rust-lang#83780 (Document "standard" conventions for error messages)
 - rust-lang#83787 (Monomorphization doc fix)
 - rust-lang#83803 (add fp-armv8 for ARM_ALLOWED_FEATURES)
 - rust-lang#83804 (Remove nightly features in rustc_type_ir)
 - rust-lang#83810 (Fix rustc_lint_defs documentation typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3b40d2c into rust-lang:master Apr 4, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 4, 2021
@CDirkx CDirkx deleted the const-socketaddr branch April 21, 2021 14:33
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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants