rust/library/std/src
bors bd2f1cb278 Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
Stabilize all stable methods of `Ipv4Addr`, `Ipv6Addr` and `IpAddr` as const

This PR stabilizes all currently stable methods of `Ipv4Addr`, `Ipv6Addr` and `IpAddr` as const.
Tracking issue: #76205

`Ipv4Addr` (`const_ipv4`):
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_multicast`
 - `is_broadcast`
 - `is_docmentation`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

`Ipv6Addr` (`const_ipv6`):
 - `segments`
 - `is_unspecified`
 - `is_loopback`
 - `is_multicast`
 - `to_ipv4`

`IpAddr` (`const_ip`):
 - `is_unspecified`
 - `is_loopback`
 - `is_multicast`

## Motivation
The ip methods seem like prime candidates to be made const: their behavior is defined by an external spec, and based solely on the byte contents of an address. These methods have been made unstable const in the beginning of September, after the necessary const integer arithmetic was stabilized.

There is currently a PR open (#78802) to change the internal representation of `IpAddr{4,6}` from `libc` types to a byte array. This does not have any impact on the constness of the methods.

## Implementation
Most of the stabilizations are straightforward, with the exception of `Ipv6Addr::segments`, which uses the unstable feature `const_fn_transmute`. The code could be rewritten to equivalent stable code, but this leads to worse code generation (#75085).
This is why `segments` gets marked with `#[rustc_allow_const_fn_unstable(const_fn_transmute)]`, like the already const-stable `Ipv6Addr::new`, the justification being that a const-stable alternative implementation exists https://github.com/rust-lang/rust/pull/76206#issuecomment-685044184.

## Future posibilities
This PR const-stabilizes all currently stable ip methods, however there are also a number of unstable methods under the `ip` feature (#27709). These methods are already unstable const. There is a PR open (#76098) to stabilize those methods, which could include const-stabilization. However, stabilizing those methods as const is dependent on `Ipv4Addr::octets` and `Ipv6Addr::segments` (covered by this PR).
2020-12-19 13:13:41 +00:00
..
backtrace Add column number support to Backtrace 2020-11-15 13:09:56 +01:00
collections Rollup merge of #78083 - ChaiTRex:master, r=m-ou-se 2020-12-19 15:15:57 +09:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
ffi Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay 2020-12-16 00:47:50 +00:00
fs std: Fix test got_symlink_permission on Windows 2020-11-16 21:09:26 +03:00
io Auto merge of #77801 - fusion-engineering-forks:pin-mutex, r=Mark-Simulacrum 2020-12-10 23:43:20 +00:00
lazy std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
memchr std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
net Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk 2020-12-19 13:13:41 +00:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Take sys/vxworks/{fd,fs,io} from sys/unix instead. 2020-10-16 06:19:00 +02:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path Refactor parse_prefix on Windows 2020-11-07 16:15:48 +01:00
prelude Edit formatting in Rust Prelude docs 2020-12-17 21:22:58 -08:00
process std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
sync Convert a bunch of intra-doc links 2020-11-07 12:50:57 -08:00
sys Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay 2020-12-16 00:47:50 +00:00
sys_common Auto merge of #77618 - fusion-engineering-forks:windows-parker, r=Amanieu 2020-12-14 16:41:14 +00:00
thread Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
time Duration::zero() -> Duration::ZERO 2020-10-21 20:44:03 -07:00
alloc.rs Add missing punctuation to std::alloc docs 2020-12-17 21:49:32 -08:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs Add column number support to Backtrace 2020-11-15 13:09:56 +01:00
env.rs Improve docs for std::env::args() 2020-09-04 14:00:09 -07:00
error.rs Rename LayoutErr to LayoutError outside of core 2020-10-08 00:40:10 -04:00
f32.rs Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se 2020-12-10 21:32:59 -08:00
f64.rs Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se 2020-12-10 21:32:59 -08:00
fs.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
future.rs Fix stabilization marker for future_readiness_fns 2020-09-15 23:12:08 +02:00
keyword_docs.rs Rollup merge of #79211 - yoshuawuyts:future-doc-alias, r=Mark-Simulacrum 2020-12-19 15:16:01 +09:00
lazy.rs Add (internal-only) SyncOnceCell::get_or_init_pin. 2020-12-08 22:57:50 +01:00
lib.rs Auto merge of #79485 - EllenNyan:stabilize_unsafe_cell_get_mut, r=m-ou-se 2020-12-18 11:39:26 +00:00
macros.rs Use ? in core/std macros 2020-10-26 07:15:37 +09:00
memchr.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
num.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
panic.rs Add tracking issue number for panic_any. 2020-10-28 21:23:45 +01:00
panicking.rs Merge set_panic and set_print into set_output_capture. 2020-11-10 21:58:13 +01:00
path.rs Clean up intra-doc links in std::path 2020-10-27 20:54:30 -07:00
primitive_docs.rs Rollup merge of #80068 - jyn514:mut-reference, r=m-ou-se 2020-12-19 15:16:05 +09:00
process.rs Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum 2020-11-23 19:01:19 +00:00
rt.rs Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
time.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00