Skip to content

Commit b42d85e

Browse files
borsgitbot
authored and
gitbot
committed
Auto merge of rust-lang#85820 - CDirkx:is_unicast_site_local, r=joshtriplett
Remove `Ipv6Addr::is_unicast_site_local` Removes the unstable method `Ipv6Addr::is_unicast_site_local`, see also rust-lang#85604 where I have tried to summarize related discussion so far. Unicast site-local addresses (`fec0::/10`) were deprecated in [IETF RFC rust-lang#3879](https://datatracker.ietf.org/doc/html/rfc3879), see also [RFC rust-lang#4291 Section 2.5.7](https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.7). Any new implementation must no longer support the special behaviour of site-local addresses. This is mentioned in the docs of `is_unicast_site_local` and already implemented in `is_unicast_global`, which considers addresses in `fec0::/10` to have global scope, thus overlapping with `is_unicast_site_local`. Given that RFC rust-lang#3879 was published in 2004, long before Rust existed, and it is specified that any new implementation must no longer support the special behaviour of site-local addresses, I don't see how a user would ever have a need for `is_unicast_site_local`. It is also confusing that currently both `is_unicast_site_local` and `is_unicast_global` can be `true` for an address, but an address can actually only have a single scope. The deprecating RFC mentions that Site-Local scope was confusing to work with and that the classification of an address as either Link-Local or Global better matches the mental model of users. There has been earlier discussion of removing `is_unicast_site_local` (rust-lang#60145 (comment)) which decided against it, but that had the incorrect assumption that the method was already stable; it is not. (This confusion arose from the placement of the unstable attribute on the entire module, instead of on individual methods, resolved in rust-lang#85672) r? `@joshtriplett` as reviewer of all the related PRs
2 parents f72135f + 17b3dc5 commit b42d85e

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

Diff for: std/src/net/ip.rs

-41
Original file line numberDiff line numberDiff line change
@@ -1346,47 +1346,6 @@ impl Ipv6Addr {
13461346
(self.segments()[0] & 0xffc0) == 0xfe80
13471347
}
13481348

1349-
/// Returns [`true`] if this is a deprecated unicast site-local address (`fec0::/10`). The
1350-
/// unicast site-local address format is defined in [RFC 4291 section 2.5.7] as:
1351-
///
1352-
/// ```no_rust
1353-
/// | 10 |
1354-
/// | bits | 54 bits | 64 bits |
1355-
/// +----------+-------------------------+----------------------------+
1356-
/// |1111111011| subnet ID | interface ID |
1357-
/// +----------+-------------------------+----------------------------+
1358-
/// ```
1359-
///
1360-
/// [RFC 4291 section 2.5.7]: https://tools.ietf.org/html/rfc4291#section-2.5.7
1361-
///
1362-
/// # Examples
1363-
///
1364-
/// ```
1365-
/// #![feature(ip)]
1366-
///
1367-
/// use std::net::Ipv6Addr;
1368-
///
1369-
/// assert_eq!(
1370-
/// Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_site_local(),
1371-
/// false
1372-
/// );
1373-
/// assert_eq!(Ipv6Addr::new(0xfec2, 0, 0, 0, 0, 0, 0, 0).is_unicast_site_local(), true);
1374-
/// ```
1375-
///
1376-
/// # Warning
1377-
///
1378-
/// As per [RFC 3879], the whole `fec0::/10` prefix is
1379-
/// deprecated. New software must not support site-local
1380-
/// addresses.
1381-
///
1382-
/// [RFC 3879]: https://tools.ietf.org/html/rfc3879
1383-
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
1384-
#[unstable(feature = "ip", issue = "27709")]
1385-
#[inline]
1386-
pub const fn is_unicast_site_local(&self) -> bool {
1387-
(self.segments()[0] & 0xffc0) == 0xfec0
1388-
}
1389-
13901349
/// Returns [`true`] if this is an address reserved for documentation
13911350
/// (`2001:db8::/32`).
13921351
///

Diff for: std/src/net/ip/tests.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ fn ipv6_properties() {
480480
let unique_local: u16 = 1 << 2;
481481
let global: u16 = 1 << 3;
482482
let unicast_link_local: u16 = 1 << 4;
483-
let unicast_site_local: u16 = 1 << 6;
484483
let unicast_global: u16 = 1 << 7;
485484
let documentation: u16 = 1 << 8;
486485
let multicast_interface_local: u16 = 1 << 9;
@@ -523,11 +522,6 @@ fn ipv6_properties() {
523522
} else {
524523
assert!(!ip!($s).is_unicast_link_local());
525524
}
526-
if ($mask & unicast_site_local) == unicast_site_local {
527-
assert!(ip!($s).is_unicast_site_local());
528-
} else {
529-
assert!(!ip!($s).is_unicast_site_local());
530-
}
531525
if ($mask & unicast_global) == unicast_global {
532526
assert!(ip!($s).is_unicast_global());
533527
} else {
@@ -581,7 +575,6 @@ fn ipv6_properties() {
581575
let unique_local: u16 = 1 << 2;
582576
let global: u16 = 1 << 3;
583577
let unicast_link_local: u16 = 1 << 4;
584-
let unicast_site_local: u16 = 1 << 6;
585578
let unicast_global: u16 = 1 << 7;
586579
let documentation: u16 = 1 << 8;
587580
let multicast_interface_local: u16 = 1 << 9;
@@ -651,7 +644,7 @@ fn ipv6_properties() {
651644
check!(
652645
"fec0::",
653646
&[0xfe, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
654-
unicast_site_local | unicast_global | global
647+
unicast_global | global
655648
);
656649

657650
check!(
@@ -889,9 +882,6 @@ fn ipv6_const() {
889882
const IS_UNICAST_LINK_LOCAL: bool = IP_ADDRESS.is_unicast_link_local();
890883
assert!(!IS_UNICAST_LINK_LOCAL);
891884

892-
const IS_UNICAST_SITE_LOCAL: bool = IP_ADDRESS.is_unicast_site_local();
893-
assert!(!IS_UNICAST_SITE_LOCAL);
894-
895885
const IS_DOCUMENTATION: bool = IP_ADDRESS.is_documentation();
896886
assert!(!IS_DOCUMENTATION);
897887

0 commit comments

Comments
 (0)