diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index 6a8a2d5b636ed..5bc987f8069f5 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -12,8 +12,8 @@ impl TryFromIntError { /// Outputs the detailed cause of converting an integer failing. #[must_use] #[unstable(feature = "try_from_int_error_kind", issue = "153978")] - pub const fn kind(&self) -> &IntErrorKind { - &self.0 + pub const fn kind(&self) -> IntErrorKind { + self.0 } } diff --git a/library/coretests/tests/nonzero.rs b/library/coretests/tests/nonzero.rs index 5efc09fd2d98e..37041e22d0dfd 100644 --- a/library/coretests/tests/nonzero.rs +++ b/library/coretests/tests/nonzero.rs @@ -285,11 +285,11 @@ fn test_nonzero_from_int_on_success() { #[test] fn test_nonzero_from_int_on_err() { - assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero); - assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero); + assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), IntErrorKind::Zero); + assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), IntErrorKind::Zero); - assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero); - assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero); + assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), IntErrorKind::Zero); + assert_eq!(NonZero::::try_from(0).unwrap_err().kind(), IntErrorKind::Zero); } #[test] diff --git a/library/coretests/tests/num/mod.rs b/library/coretests/tests/num/mod.rs index f892734d8b95d..46e5ee0213b04 100644 --- a/library/coretests/tests/num/mod.rs +++ b/library/coretests/tests/num/mod.rs @@ -388,17 +388,14 @@ macro_rules! test_impl_try_from_integer_to_bool { let zero: $source = 0; let one: $source = 1; let two: $source = 2; - assert_eq!(bool::try_from(max).unwrap_err().kind(), &IntErrorKind::PosOverflow); + assert_eq!(bool::try_from(max).unwrap_err().kind(), IntErrorKind::PosOverflow); if min != 0 { - assert_eq!(bool::try_from(min).unwrap_err().kind(), &IntErrorKind::NegOverflow); - assert_eq!( - bool::try_from(zero - 1).unwrap_err().kind(), - &IntErrorKind::NegOverflow - ); + assert_eq!(bool::try_from(min).unwrap_err().kind(), IntErrorKind::NegOverflow); + assert_eq!(bool::try_from(zero - 1).unwrap_err().kind(), IntErrorKind::NegOverflow); } assert_eq!(bool::try_from(zero).unwrap(), false); assert_eq!(bool::try_from(one).unwrap(), true); - assert_eq!(bool::try_from(two).unwrap_err().kind(), &IntErrorKind::PosOverflow); + assert_eq!(bool::try_from(two).unwrap_err().kind(), IntErrorKind::PosOverflow); } }; } @@ -540,12 +537,12 @@ macro_rules! test_impl_try_from_signed_to_unsigned_upper_ok { assert_eq!(<$target as TryFrom<$source>>::try_from(max).unwrap(), max as $target); assert_eq!( <$target as TryFrom<$source>>::try_from(min).unwrap_err().kind(), - &IntErrorKind::NegOverflow + IntErrorKind::NegOverflow ); assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target); assert_eq!( <$target as TryFrom<$source>>::try_from(neg_one).unwrap_err().kind(), - &IntErrorKind::NegOverflow + IntErrorKind::NegOverflow ); } }; @@ -609,7 +606,7 @@ macro_rules! test_impl_try_from_unsigned_to_signed_upper_err { let zero: $source = 0; assert_eq!( <$target as TryFrom<$source>>::try_from(max).unwrap_err().kind(), - &IntErrorKind::PosOverflow + IntErrorKind::PosOverflow ); assert_eq!(<$target as TryFrom<$source>>::try_from(min).unwrap(), min as $target); assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target); @@ -675,12 +672,12 @@ macro_rules! test_impl_try_from_same_sign_err { let t_min = <$target>::MIN; assert_eq!( <$target as TryFrom<$source>>::try_from(max).unwrap_err().kind(), - &IntErrorKind::PosOverflow + IntErrorKind::PosOverflow ); if min != 0 { assert_eq!( <$target as TryFrom<$source>>::try_from(min).unwrap_err().kind(), - &IntErrorKind::NegOverflow + IntErrorKind::NegOverflow ); } assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target); @@ -770,11 +767,11 @@ macro_rules! test_impl_try_from_signed_to_unsigned_err { let t_min = <$target>::MIN; assert_eq!( <$target as TryFrom<$source>>::try_from(max).unwrap_err().kind(), - &IntErrorKind::PosOverflow + IntErrorKind::PosOverflow ); assert_eq!( <$target as TryFrom<$source>>::try_from(min).unwrap_err().kind(), - &IntErrorKind::NegOverflow + IntErrorKind::NegOverflow ); assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target); assert_eq!(