Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions library/core/src/num/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
8 changes: 4 additions & 4 deletions library/coretests/tests/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ fn test_nonzero_from_int_on_success() {

#[test]
fn test_nonzero_from_int_on_err() {
assert_eq!(NonZero::<u8>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<u32>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<u8>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);
assert_eq!(NonZero::<u32>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);

assert_eq!(NonZero::<i8>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<i32>::try_from(0).unwrap_err().kind(), &IntErrorKind::Zero);
assert_eq!(NonZero::<i8>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);
assert_eq!(NonZero::<i32>::try_from(0).unwrap_err().kind(), IntErrorKind::Zero);
}

#[test]
Expand Down
25 changes: 11 additions & 14 deletions library/coretests/tests/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
}
Expand Down Expand Up @@ -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
);
}
};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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!(
Expand Down
Loading