@@ -426,6 +426,8 @@ impl IpAddr {
426426 /// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true);
427427 /// ```
428428 #[ inline]
429+ #[ must_use = "this returns the result of the operation, \
430+ without modifying the original"]
429431 #[ rustc_const_unstable( feature = "const_ip" , issue = "76205" ) ]
430432 #[ unstable( feature = "ip" , issue = "27709" ) ]
431433 pub const fn to_canonical ( & self ) -> IpAddr {
@@ -901,6 +903,8 @@ impl Ipv4Addr {
901903 /// ```
902904 #[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
903905 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
906+ #[ must_use = "this returns the result of the operation, \
907+ without modifying the original"]
904908 #[ inline]
905909 pub const fn to_ipv6_compatible ( & self ) -> Ipv6Addr {
906910 let [ a, b, c, d] = self . octets ( ) ;
@@ -926,6 +930,8 @@ impl Ipv4Addr {
926930 /// ```
927931 #[ rustc_const_stable( feature = "const_ipv4" , since = "1.50.0" ) ]
928932 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
933+ #[ must_use = "this returns the result of the operation, \
934+ without modifying the original"]
929935 #[ inline]
930936 pub const fn to_ipv6_mapped ( & self ) -> Ipv6Addr {
931937 let [ a, b, c, d] = self . octets ( ) ;
@@ -1648,6 +1654,8 @@ impl Ipv6Addr {
16481654 /// ```
16491655 #[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
16501656 #[ unstable( feature = "ip" , issue = "27709" ) ]
1657+ #[ must_use = "this returns the result of the operation, \
1658+ without modifying the original"]
16511659 #[ inline]
16521660 pub const fn to_ipv4_mapped ( & self ) -> Option < Ipv4Addr > {
16531661 match self . octets ( ) {
@@ -1685,6 +1693,8 @@ impl Ipv6Addr {
16851693 /// ```
16861694 #[ rustc_const_stable( feature = "const_ipv6" , since = "1.50.0" ) ]
16871695 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1696+ #[ must_use = "this returns the result of the operation, \
1697+ without modifying the original"]
16881698 #[ inline]
16891699 pub const fn to_ipv4 ( & self ) -> Option < Ipv4Addr > {
16901700 if let [ 0 , 0 , 0 , 0 , 0 , 0 | 0xffff , ab, cd] = self . segments ( ) {
@@ -1708,9 +1718,11 @@ impl Ipv6Addr {
17081718 /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false);
17091719 /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true);
17101720 /// ```
1711- #[ inline]
17121721 #[ rustc_const_unstable( feature = "const_ipv6" , issue = "76205" ) ]
17131722 #[ unstable( feature = "ip" , issue = "27709" ) ]
1723+ #[ must_use = "this returns the result of the operation, \
1724+ without modifying the original"]
1725+ #[ inline]
17141726 pub const fn to_canonical ( & self ) -> IpAddr {
17151727 if let Some ( mapped) = self . to_ipv4_mapped ( ) {
17161728 return IpAddr :: V4 ( mapped) ;
0 commit comments