diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 0ebac027c39ac..c6c91dacdc7ee 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2627,8 +2627,11 @@ try_from_both_bounded!(i32, u16, u8); try_from_both_bounded!(i64, u32, u16, u8); try_from_both_bounded!(i128, u64, u32, u16, u8); -#[unstable(feature = "try_from", issue = "33417")] -pub use self::ptr_try_from_impls::*; +// usize/isize +try_from_unbounded!(usize, usize); +try_from_upper_bounded!(usize, isize); +try_from_lower_bounded!(isize, usize); +try_from_unbounded!(isize, isize); #[cfg(target_pointer_width = "16")] mod ptr_try_from_impls { @@ -2636,12 +2639,12 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); - try_from_unbounded!(usize, usize, u16, u32, u64, u128); - try_from_upper_bounded!(usize, i8, i16, isize); + try_from_unbounded!(usize, u16, u32, u64, u128); + try_from_upper_bounded!(usize, i8, i16); try_from_unbounded!(usize, i32, i64, i128); try_from_both_bounded!(isize, u8); - try_from_lower_bounded!(isize, usize, u16, u32, u64, u128); + try_from_lower_bounded!(isize, u16, u32, u64, u128); try_from_both_bounded!(isize, i8); try_from_unbounded!(isize, i16, i32, i64, i128); @@ -2662,12 +2665,12 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); - try_from_unbounded!(usize, usize, u32, u64, u128); - try_from_upper_bounded!(usize, i8, i16, i32, isize); + try_from_unbounded!(usize, u32, u64, u128); + try_from_upper_bounded!(usize, i8, i16, i32); try_from_unbounded!(usize, i64, i128); try_from_both_bounded!(isize, u8, u16); - try_from_lower_bounded!(isize, usize, u32, u64, u128); + try_from_lower_bounded!(isize, u32, u64, u128); try_from_both_bounded!(isize, i8, i16); try_from_unbounded!(isize, i32, i64, i128); @@ -2688,12 +2691,12 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); - try_from_unbounded!(usize, usize, u64, u128); - try_from_upper_bounded!(usize, i8, i16, i32, i64, isize); + try_from_unbounded!(usize, u64, u128); + try_from_upper_bounded!(usize, i8, i16, i32, i64); try_from_unbounded!(usize, i128); try_from_both_bounded!(isize, u8, u16, u32); - try_from_lower_bounded!(isize, usize, u64, u128); + try_from_lower_bounded!(isize, u64, u128); try_from_both_bounded!(isize, i8, i16, i32); try_from_unbounded!(isize, i64, i128); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index 3e872b34e433d..046b81e19f70d 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -279,7 +279,7 @@ test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } -test_impl_try_from_always_ok! { test_try_u128, u128, u128 } +test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } @@ -301,8 +301,12 @@ test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } +test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } +test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } + assume_usize_width! { test_impl_try_from_always_ok! { test_try_u8usize, u8, usize } + test_impl_try_from_always_ok! { test_try_u8isize, u8, isize } test_impl_try_from_always_ok! { test_try_i8isize, i8, isize } test_impl_try_from_always_ok! { test_try_u16usize, u16, usize } @@ -317,19 +321,27 @@ assume_usize_width! { cfg_block!( #[cfg(target_pointer_width = "16")] { - test_impl_try_from_always_ok! { test_try_u16usize, u16, usize } - test_impl_try_from_always_ok! { test_try_i16isize, i16, isize } + test_impl_try_from_always_ok! { test_try_usizeu16, usize, u16 } + test_impl_try_from_always_ok! { test_try_isizei16, isize, i16 } + test_impl_try_from_always_ok! { test_try_usizeu32, usize, u32 } + test_impl_try_from_always_ok! { test_try_usizei32, usize, i32 } + test_impl_try_from_always_ok! { test_try_isizei32, isize, i32 } + test_impl_try_from_always_ok! { test_try_usizei64, usize, i64 } } #[cfg(target_pointer_width = "32")] { + test_impl_try_from_always_ok! { test_try_u16isize, u16, isize } test_impl_try_from_always_ok! { test_try_usizeu32, usize, u32 } test_impl_try_from_always_ok! { test_try_isizei32, isize, i32 } test_impl_try_from_always_ok! { test_try_u32usize, u32, usize } test_impl_try_from_always_ok! { test_try_i32isize, i32, isize } + test_impl_try_from_always_ok! { test_try_usizei64, usize, i64 } } #[cfg(target_pointer_width = "64")] { + test_impl_try_from_always_ok! { test_try_u16isize, u16, isize } test_impl_try_from_always_ok! { test_try_u32usize, u32, usize } + test_impl_try_from_always_ok! { test_try_u32isize, u32, isize } test_impl_try_from_always_ok! { test_try_i32isize, i32, isize } test_impl_try_from_always_ok! { test_try_u64usize, u64, usize } test_impl_try_from_always_ok! { test_try_i64isize, i64, isize } @@ -451,8 +463,8 @@ assume_usize_width! { cfg_block!( #[cfg(target_pointer_width = "16")] { + test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u16isize, u16, isize } test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u32isize, u32, isize } - test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u32isize, u64, isize } } #[cfg(target_pointer_width = "32")] {