@@ -418,6 +418,8 @@ impl IpAddr {
418418 /// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true);
419419 /// ```
420420 #[ inline]
421+ #[ must_use = "this returns the result of the operation, \
422+ without modifying the original"]
421423 #[ rustc_const_unstable( feature = "const_ip" , issue = "76205" ) ]
422424 #[ unstable( feature = "ip" , issue = "27709" ) ]
423425 pub const fn to_canonical ( & self ) -> IpAddr {
@@ -882,6 +884,8 @@ impl Ipv4Addr {
882884 /// ```
883885 #[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
884886 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
887+ #[ must_use = "this returns the result of the operation, \
888+ without modifying the original"]
885889 #[ inline]
886890 pub const fn to_ipv6_compatible ( & self ) -> Ipv6Addr {
887891 let [ a, b, c, d] = self . octets ( ) ;
@@ -907,6 +911,8 @@ impl Ipv4Addr {
907911 /// ```
908912 #[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
909913 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
914+ #[ must_use = "this returns the result of the operation, \
915+ without modifying the original"]
910916 #[ inline]
911917 pub const fn to_ipv6_mapped ( & self ) -> Ipv6Addr {
912918 let [ a, b, c, d] = self . octets ( ) ;
@@ -1619,6 +1625,8 @@ impl Ipv6Addr {
16191625 /// ```
16201626 #[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
16211627 #[ unstable( feature = "ip" , issue = "27709" ) ]
1628+ #[ must_use = "this returns the result of the operation, \
1629+ without modifying the original"]
16221630 #[ inline]
16231631 pub const fn to_ipv4_mapped ( & self ) -> Option < Ipv4Addr > {
16241632 match self . octets ( ) {
@@ -1656,6 +1664,8 @@ impl Ipv6Addr {
16561664 /// ```
16571665 #[ rustc_const_stable( feature = "const_ipv6" , since = "1.50.0" ) ]
16581666 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1667+ #[ must_use = "this returns the result of the operation, \
1668+ without modifying the original"]
16591669 #[ inline]
16601670 pub const fn to_ipv4 ( & self ) -> Option < Ipv4Addr > {
16611671 if let [ 0 , 0 , 0 , 0 , 0 , 0 | 0xffff , ab, cd] = self . segments ( ) {
@@ -1679,9 +1689,11 @@ impl Ipv6Addr {
16791689 /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false);
16801690 /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true);
16811691 /// ```
1682- #[ inline]
16831692 #[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
16841693 #[ unstable( feature = "ip" , issue = "27709" ) ]
1694+ #[ must_use = "this returns the result of the operation, \
1695+ without modifying the original"]
1696+ #[ inline]
16851697 pub const fn to_canonical ( & self ) -> IpAddr {
16861698 if let Some ( mapped) = self . to_ipv4_mapped ( ) {
16871699 return IpAddr :: V4 ( mapped) ;
0 commit comments