Skip to content

Stabilize the "IP" feature #76098

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

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1a127d5
stabilize the "ip" feature and document stability guarantees
little-dude Nov 20, 2019
0910bbc
std::net: add Ipv6Multicastscope variants
little-dude Jan 12, 2020
67742d4
Update feature gates
caass Sep 4, 2020
d3fea20
Apply suggestions from code review
caass Sep 4, 2020
22520cf
`is_unicast_link_local_strict` --> `is_unicast_link_local`
caass Sep 4, 2020
2c005cb
Add checking for ipv4-(mapped | compatible) addresses
caass Sep 4, 2020
707770c
Add stability attributes to Ipv6MulticastScope
caass Sep 4, 2020
133c62d
remove `/// #![feature(ip)]` tags from doc tests
caass Sep 4, 2020
23f40a3
Remove some more #![feature(ip)] stuff
caass Sep 4, 2020
46bdfcb
Remove some code having to do with link-local strict
caass Sep 4, 2020
ec63c55
Change checks for is_unicast_link_local_strict to is_unicast_link_local
caass Oct 6, 2020
6e6f745
Rewrite ipv4 checks to check ipv6 stuff first
caass Oct 6, 2020
341dc82
Fix test cases that checked for relaxed behavior
caass Oct 7, 2020
c90cc3d
Restore the relaxed behavior of `is_unicast_link_local`
caass Oct 21, 2020
8364ac0
Revert "Fix test cases that checked for relaxed behavior"
caass Oct 21, 2020
3cf1541
Remove IP feature gate
caass Oct 21, 2020
96d1165
Remove duplicate UI tests as per @CDirkx's suggestions
caass Nov 24, 2020
3825105
Rewrite using new rustdoc comments!!!!
caass Nov 24, 2020
18773f9
Adjust Ipv4-in-Ipv6 checking to ignore Ipv4-compatible addresses
caass Nov 25, 2020
a0d0771
Revert "Adjust Ipv4-in-Ipv6 checking to ignore Ipv4-compatible addres…
caass Nov 25, 2020
2c836b5
Update doc comments
caass Nov 25, 2020
e3487cf
stop treating `::ffff:0.0.0.0` as unspecified
caass Feb 6, 2021
a1d4e70
wow i hope i didn't mess something up
caass Feb 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove some more #![feature(ip)] stuff
Getting kind of extremely out of my comfort zone here and modifying quite a few different files...i hope this is all ok...
  • Loading branch information
caass committed Feb 28, 2021
commit 23f40a3a799a42ccf41e8b8a2415974a1c08e679
57 changes: 57 additions & 0 deletions src/test/ui/consts/std/net/ipv4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// run-pass

#![feature(const_ipv4)]

use std::net::{Ipv4Addr, Ipv6Addr};

fn main() {
const IP_ADDRESS: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1);
assert_eq!(IP_ADDRESS, Ipv4Addr::LOCALHOST);

const OCTETS: [u8; 4] = IP_ADDRESS.octets();
assert_eq!(OCTETS, [127, 0, 0, 1]);

const IS_UNSPECIFIED : bool = IP_ADDRESS.is_unspecified();
assert!(!IS_UNSPECIFIED);

const IS_LOOPBACK : bool = IP_ADDRESS.is_loopback();
assert!(IS_LOOPBACK);

const IS_PRIVATE : bool = IP_ADDRESS.is_private();
assert!(!IS_PRIVATE);

const IS_LINK_LOCAL : bool = IP_ADDRESS.is_link_local();
assert!(!IS_LINK_LOCAL);

const IS_GLOBAL : bool = IP_ADDRESS.is_global();
assert!(!IS_GLOBAL);

const IS_SHARED : bool = IP_ADDRESS.is_shared();
assert!(!IS_SHARED);

const IS_IETF_PROTOCOL_ASSIGNMENT : bool = IP_ADDRESS.is_ietf_protocol_assignment();
assert!(!IS_IETF_PROTOCOL_ASSIGNMENT);

const IS_BENCHMARKING : bool = IP_ADDRESS.is_benchmarking();
assert!(!IS_BENCHMARKING);

const IS_RESERVED : bool = IP_ADDRESS.is_reserved();
assert!(!IS_RESERVED);

const IS_MULTICAST : bool = IP_ADDRESS.is_multicast();
assert!(!IS_MULTICAST);

const IS_BROADCAST : bool = IP_ADDRESS.is_broadcast();
assert!(!IS_BROADCAST);

const IS_DOCUMENTATION : bool = IP_ADDRESS.is_documentation();
assert!(!IS_DOCUMENTATION);

const IP_V6_COMPATIBLE : Ipv6Addr = IP_ADDRESS.to_ipv6_compatible();
assert_eq!(IP_V6_COMPATIBLE,
Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]));

const IP_V6_MAPPED : Ipv6Addr = IP_ADDRESS.to_ipv6_mapped();
assert_eq!(IP_V6_MAPPED,
Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1]));
}
52 changes: 52 additions & 0 deletions src/test/ui/consts/std/net/ipv6.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// run-pass

#![feature(const_ipv6)]

use std::net::{Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};

fn main() {
const IP_ADDRESS : Ipv6Addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
assert_eq!(IP_ADDRESS, Ipv6Addr::LOCALHOST);

const SEGMENTS : [u16; 8] = IP_ADDRESS.segments();
assert_eq!(SEGMENTS, [0 ,0 ,0 ,0 ,0 ,0 ,0, 1]);

const OCTETS : [u8; 16] = IP_ADDRESS.octets();
assert_eq!(OCTETS, [0 ,0 ,0 ,0 ,0 ,0 ,0, 0 ,0 ,0 ,0 ,0 ,0 ,0, 0, 1]);

const IS_UNSPECIFIED : bool = IP_ADDRESS.is_unspecified();
assert!(!IS_UNSPECIFIED);

const IS_LOOPBACK : bool = IP_ADDRESS.is_loopback();
assert!(IS_LOOPBACK);

const IS_GLOBAL : bool = IP_ADDRESS.is_global();
assert!(!IS_GLOBAL);

const IS_UNIQUE_LOCAL : bool = IP_ADDRESS.is_unique_local();
assert!(!IS_UNIQUE_LOCAL);

const IS_UNICAST_LINK_LOCAL_STRICT : bool = IP_ADDRESS.is_unicast_link_local_strict();
assert!(!IS_UNICAST_LINK_LOCAL_STRICT);

const IS_UNICAST_LINK_LOCAL : bool = IP_ADDRESS.is_unicast_link_local();
assert!(!IS_UNICAST_LINK_LOCAL);

const IS_UNICAST_SITE_LOCAL : bool = IP_ADDRESS.is_unicast_site_local();
assert!(!IS_UNICAST_SITE_LOCAL);

const IS_DOCUMENTATION : bool = IP_ADDRESS.is_documentation();
assert!(!IS_DOCUMENTATION);

const IS_UNICAST_GLOBAL : bool = IP_ADDRESS.is_unicast_global();
assert!(!IS_UNICAST_GLOBAL);

const MULTICAST_SCOPE : Option<Ipv6MulticastScope> = IP_ADDRESS.multicast_scope();
assert_eq!(MULTICAST_SCOPE, None);

const IS_MULTICAST : bool = IP_ADDRESS.is_multicast();
assert!(!IS_MULTICAST);

const IP_V4 : Option<Ipv4Addr> = IP_ADDRESS.to_ipv4();
assert_eq!(IP_V4.unwrap(), Ipv4Addr::new(0, 0, 0, 1));
}