Auto merge of #52872 - faern:use-modern-alignment-libc, r=TimNN
Make IpvXAddr::new const fns and the well known addresses associated constants Implements/fixes https://github.com/rust-lang/rust/issues/44582 I just got a PR towards libc (https://github.com/rust-lang/libc/pull/1044) merged. With the new feature added in that PR it is now possible to create `in6_addr` instances as consts. This enables us to finally make the constructors of the IP structs const fns and to make the localhost/unspecified addresses associated constants, as agreed in the above mentioned tracking issue. I also added a BROADCAST constant. Personally this is the well known address I tend to need the most often.
This commit is contained in:
commit
ebe8df41d7
6 changed files with 118 additions and 99 deletions
|
|
@ -90,7 +90,7 @@ name = "atty"
|
|||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -102,7 +102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -113,7 +113,7 @@ version = "0.1.23"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -136,7 +136,7 @@ dependencies = [
|
|||
"filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"petgraph 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -196,7 +196,7 @@ dependencies = [
|
|||
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libgit2-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -243,7 +243,7 @@ dependencies = [
|
|||
"jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazycell 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libgit2-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -426,7 +426,7 @@ name = "commoncrypto-sys"
|
|||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -446,7 +446,7 @@ dependencies = [
|
|||
"filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -465,7 +465,7 @@ dependencies = [
|
|||
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -488,7 +488,7 @@ version = "0.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -497,7 +497,7 @@ version = "0.6.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -505,7 +505,7 @@ name = "core-foundation-sys"
|
|||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -627,7 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"curl-sys 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"schannel 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -641,7 +641,7 @@ version = "0.4.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -790,7 +790,7 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -804,7 +804,7 @@ name = "flate2"
|
|||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -835,7 +835,7 @@ name = "fs2"
|
|||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -887,7 +887,7 @@ version = "0.7.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libgit2-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -1035,7 +1035,7 @@ name = "isatty"
|
|||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -1058,7 +1058,7 @@ name = "jobserver"
|
|||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -1129,7 +1129,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.42"
|
||||
version = "0.2.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1140,7 +1140,7 @@ dependencies = [
|
|||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cmake 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"curl-sys 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libssh2-sys 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -1153,7 +1153,7 @@ version = "0.2.8"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cmake 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -1166,7 +1166,7 @@ version = "1.0.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -1206,7 +1206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -1273,7 +1273,7 @@ name = "memchr"
|
|||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1281,7 +1281,7 @@ name = "memmap"
|
|||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -1304,7 +1304,7 @@ version = "0.1.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1372,7 +1372,7 @@ name = "num_cpus"
|
|||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1389,7 +1389,7 @@ dependencies = [
|
|||
"cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -1404,7 +1404,7 @@ version = "0.9.33"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vcpkg 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -1461,7 +1461,7 @@ name = "parking_lot_core"
|
|||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -1657,7 +1657,7 @@ version = "0.4.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
@ -1668,7 +1668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -1694,7 +1694,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -2024,7 +2024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -2586,7 +2586,7 @@ version = "0.3.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -2764,7 +2764,7 @@ version = "0.4.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -2774,7 +2774,7 @@ name = "tempfile"
|
|||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -2825,7 +2825,7 @@ name = "termion"
|
|||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -2869,7 +2869,7 @@ name = "time"
|
|||
version = "0.1.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -3069,7 +3069,7 @@ name = "xattr"
|
|||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3181,7 +3181,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb497c35d362b6a331cfd94956a07fc2c78a4604cdbee844a81170386b996dd3"
|
||||
"checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef"
|
||||
"checksum lazycell 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d33a48d0365c96081958cc663eef834975cb1e8d8bea3378513fc72bdbf11e50"
|
||||
"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1"
|
||||
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
||||
"checksum libgit2-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c9051a4b288ba6f8728e9e52bb2510816946b8bcb2e20259e4d4cdc93b9ecafd"
|
||||
"checksum libssh2-sys 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c628b499e8d1a4f4bd09a95d6cb1f8aeb231b46a9d40959bbd0408f14dd63adf"
|
||||
"checksum libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "87f737ad6cc6fd6eefe3d9dc5412f1573865bded441300904d2f42269e140f16"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit b6d23ed45d72918239c0bfac11dc547895e59b81
|
||||
Subproject commit 6bdbf5dc937459bd10e6bc4dc52b0adbd8cf4358
|
||||
|
|
@ -252,6 +252,8 @@
|
|||
#![feature(char_error_internals)]
|
||||
#![feature(compiler_builtins_lib)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_int_ops)]
|
||||
#![feature(const_ip)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(dropck_eyepatch)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
|
|
@ -281,6 +283,7 @@
|
|||
#![feature(ptr_internals)]
|
||||
#![feature(raw)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(rustc_const_unstable)]
|
||||
#![feature(std_internals)]
|
||||
#![feature(stdsimd)]
|
||||
#![feature(shrink_to)]
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
use cmp::Ordering;
|
||||
use fmt;
|
||||
use hash;
|
||||
use mem;
|
||||
use net::{hton, ntoh};
|
||||
use sys::net::netc as c;
|
||||
use sys_common::{AsInner, FromInner};
|
||||
|
||||
|
|
@ -340,18 +338,21 @@ impl Ipv4Addr {
|
|||
/// let addr = Ipv4Addr::new(127, 0, 0, 1);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
|
||||
#[rustc_const_unstable(feature = "const_ip")]
|
||||
pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
|
||||
Ipv4Addr {
|
||||
inner: c::in_addr {
|
||||
s_addr: hton(((a as u32) << 24) |
|
||||
((b as u32) << 16) |
|
||||
((c as u32) << 8) |
|
||||
(d as u32)),
|
||||
s_addr: u32::to_be(
|
||||
((a as u32) << 24) |
|
||||
((b as u32) << 16) |
|
||||
((c as u32) << 8) |
|
||||
(d as u32)
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new IPv4 address with the address pointing to localhost: 127.0.0.1.
|
||||
/// An IPv4 address with the address pointing to localhost: 127.0.0.1.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -359,17 +360,15 @@ impl Ipv4Addr {
|
|||
/// #![feature(ip_constructors)]
|
||||
/// use std::net::Ipv4Addr;
|
||||
///
|
||||
/// let addr = Ipv4Addr::localhost();
|
||||
/// let addr = Ipv4Addr::LOCALHOST;
|
||||
/// assert_eq!(addr, Ipv4Addr::new(127, 0, 0, 1));
|
||||
/// ```
|
||||
#[unstable(feature = "ip_constructors",
|
||||
reason = "requires greater scrutiny before stabilization",
|
||||
issue = "44582")]
|
||||
pub fn localhost() -> Ipv4Addr {
|
||||
Ipv4Addr::new(127, 0, 0, 1)
|
||||
}
|
||||
pub const LOCALHOST: Self = Ipv4Addr::new(127, 0, 0, 1);
|
||||
|
||||
/// Creates a new IPv4 address representing an unspecified address: 0.0.0.0
|
||||
/// An IPv4 address representing an unspecified address: 0.0.0.0
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -377,15 +376,29 @@ impl Ipv4Addr {
|
|||
/// #![feature(ip_constructors)]
|
||||
/// use std::net::Ipv4Addr;
|
||||
///
|
||||
/// let addr = Ipv4Addr::unspecified();
|
||||
/// let addr = Ipv4Addr::UNSPECIFIED;
|
||||
/// assert_eq!(addr, Ipv4Addr::new(0, 0, 0, 0));
|
||||
/// ```
|
||||
#[unstable(feature = "ip_constructors",
|
||||
reason = "requires greater scrutiny before stabilization",
|
||||
issue = "44582")]
|
||||
pub fn unspecified() -> Ipv4Addr {
|
||||
Ipv4Addr::new(0, 0, 0, 0)
|
||||
}
|
||||
pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0);
|
||||
|
||||
/// An IPv4 address representing the broadcast address: 255.255.255.255
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(ip_constructors)]
|
||||
/// use std::net::Ipv4Addr;
|
||||
///
|
||||
/// let addr = Ipv4Addr::BROADCAST;
|
||||
/// assert_eq!(addr, Ipv4Addr::new(255, 255, 255, 255));
|
||||
/// ```
|
||||
#[unstable(feature = "ip_constructors",
|
||||
reason = "requires greater scrutiny before stabilization",
|
||||
issue = "44582")]
|
||||
pub const BROADCAST: Self = Ipv4Addr::new(255, 255, 255, 255);
|
||||
|
||||
/// Returns the four eight-bit integers that make up this address.
|
||||
///
|
||||
|
|
@ -399,7 +412,7 @@ impl Ipv4Addr {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn octets(&self) -> [u8; 4] {
|
||||
let bits = ntoh(self.inner.s_addr);
|
||||
let bits = u32::from_be(self.inner.s_addr);
|
||||
[(bits >> 24) as u8, (bits >> 16) as u8, (bits >> 8) as u8, bits as u8]
|
||||
}
|
||||
|
||||
|
|
@ -573,8 +586,7 @@ impl Ipv4Addr {
|
|||
/// ```
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
pub fn is_broadcast(&self) -> bool {
|
||||
self.octets()[0] == 255 && self.octets()[1] == 255 &&
|
||||
self.octets()[2] == 255 && self.octets()[3] == 255
|
||||
self == &Self::BROADCAST
|
||||
}
|
||||
|
||||
/// Returns [`true`] if this address is in a range designated for documentation.
|
||||
|
|
@ -763,7 +775,7 @@ impl PartialOrd<IpAddr> for Ipv4Addr {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl Ord for Ipv4Addr {
|
||||
fn cmp(&self, other: &Ipv4Addr) -> Ordering {
|
||||
ntoh(self.inner.s_addr).cmp(&ntoh(other.inner.s_addr))
|
||||
u32::from_be(self.inner.s_addr).cmp(&u32::from_be(other.inner.s_addr))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -856,21 +868,27 @@ impl Ipv6Addr {
|
|||
/// let addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
|
||||
h: u16) -> Ipv6Addr {
|
||||
let mut addr: c::in6_addr = unsafe { mem::zeroed() };
|
||||
addr.s6_addr = [(a >> 8) as u8, a as u8,
|
||||
(b >> 8) as u8, b as u8,
|
||||
(c >> 8) as u8, c as u8,
|
||||
(d >> 8) as u8, d as u8,
|
||||
(e >> 8) as u8, e as u8,
|
||||
(f >> 8) as u8, f as u8,
|
||||
(g >> 8) as u8, g as u8,
|
||||
(h >> 8) as u8, h as u8];
|
||||
Ipv6Addr { inner: addr }
|
||||
#[rustc_const_unstable(feature = "const_ip")]
|
||||
pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16,
|
||||
g: u16, h: u16) -> Ipv6Addr {
|
||||
Ipv6Addr {
|
||||
inner: c::in6_addr {
|
||||
s6_addr: [
|
||||
(a >> 8) as u8, a as u8,
|
||||
(b >> 8) as u8, b as u8,
|
||||
(c >> 8) as u8, c as u8,
|
||||
(d >> 8) as u8, d as u8,
|
||||
(e >> 8) as u8, e as u8,
|
||||
(f >> 8) as u8, f as u8,
|
||||
(g >> 8) as u8, g as u8,
|
||||
(h >> 8) as u8, h as u8
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Creates a new IPv6 address representing localhost: `::1`.
|
||||
/// An IPv6 address representing localhost: `::1`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -878,17 +896,15 @@ impl Ipv6Addr {
|
|||
/// #![feature(ip_constructors)]
|
||||
/// use std::net::Ipv6Addr;
|
||||
///
|
||||
/// let addr = Ipv6Addr::localhost();
|
||||
/// let addr = Ipv6Addr::LOCALHOST;
|
||||
/// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
|
||||
/// ```
|
||||
#[unstable(feature = "ip_constructors",
|
||||
reason = "requires greater scrutiny before stabilization",
|
||||
issue = "44582")]
|
||||
pub fn localhost() -> Ipv6Addr {
|
||||
Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)
|
||||
}
|
||||
pub const LOCALHOST: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
/// Creates a new IPv6 address representing the unspecified address: `::`
|
||||
/// An IPv6 address representing the unspecified address: `::`
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -896,15 +912,13 @@ impl Ipv6Addr {
|
|||
/// #![feature(ip_constructors)]
|
||||
/// use std::net::Ipv6Addr;
|
||||
///
|
||||
/// let addr = Ipv6Addr::unspecified();
|
||||
/// let addr = Ipv6Addr::UNSPECIFIED;
|
||||
/// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
|
||||
/// ```
|
||||
#[unstable(feature = "ip_constructors",
|
||||
reason = "requires greater scrutiny before stabilization",
|
||||
issue = "44582")]
|
||||
pub fn unspecified() -> Ipv6Addr {
|
||||
Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)
|
||||
}
|
||||
pub const UNSPECIFIED: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
/// Returns the eight 16-bit segments that make up this address.
|
||||
///
|
||||
|
|
@ -1414,8 +1428,7 @@ impl From<u128> for Ipv6Addr {
|
|||
#[stable(feature = "ipv6_from_octets", since = "1.9.0")]
|
||||
impl From<[u8; 16]> for Ipv6Addr {
|
||||
fn from(octets: [u8; 16]) -> Ipv6Addr {
|
||||
let mut inner: c::in6_addr = unsafe { mem::zeroed() };
|
||||
inner.s6_addr = octets;
|
||||
let inner = c::in6_addr { s6_addr: octets };
|
||||
Ipv6Addr::from_inner(inner)
|
||||
}
|
||||
}
|
||||
|
|
@ -1846,18 +1859,20 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn ipv4_from_constructors() {
|
||||
assert_eq!(Ipv4Addr::localhost(), Ipv4Addr::new(127, 0, 0, 1));
|
||||
assert!(Ipv4Addr::localhost().is_loopback());
|
||||
assert_eq!(Ipv4Addr::unspecified(), Ipv4Addr::new(0, 0, 0, 0));
|
||||
assert!(Ipv4Addr::unspecified().is_unspecified());
|
||||
assert_eq!(Ipv4Addr::LOCALHOST, Ipv4Addr::new(127, 0, 0, 1));
|
||||
assert!(Ipv4Addr::LOCALHOST.is_loopback());
|
||||
assert_eq!(Ipv4Addr::UNSPECIFIED, Ipv4Addr::new(0, 0, 0, 0));
|
||||
assert!(Ipv4Addr::UNSPECIFIED.is_unspecified());
|
||||
assert_eq!(Ipv4Addr::BROADCAST, Ipv4Addr::new(255, 255, 255, 255));
|
||||
assert!(Ipv4Addr::BROADCAST.is_broadcast());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ipv6_from_contructors() {
|
||||
assert_eq!(Ipv6Addr::localhost(), Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
|
||||
assert!(Ipv6Addr::localhost().is_loopback());
|
||||
assert_eq!(Ipv6Addr::unspecified(), Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
|
||||
assert!(Ipv6Addr::unspecified().is_unspecified());
|
||||
assert_eq!(Ipv6Addr::LOCALHOST, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
|
||||
assert!(Ipv6Addr::LOCALHOST.is_loopback());
|
||||
assert_eq!(Ipv6Addr::UNSPECIFIED, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
|
||||
assert!(Ipv6Addr::UNSPECIFIED.is_unspecified());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ pub struct in_addr {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(align(4))]
|
||||
#[repr(C)]
|
||||
pub struct in6_addr {
|
||||
pub s6_addr: [u8; 16],
|
||||
__align: [u32; 0],
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
|||
|
|
@ -36,4 +36,5 @@ compiler_builtins = { path = "../compiler_builtins_shim" }
|
|||
# Certain parts of libc are conditionally compiled differently than when used
|
||||
# outside rustc. See https://github.com/rust-lang/libc/search?l=Rust&q=stdbuild&type=&utf8=%E2%9C%93.
|
||||
stdbuild = []
|
||||
default = ["stdbuild"]
|
||||
default = ["stdbuild", "align"]
|
||||
align = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue