@@ -2507,10 +2507,12 @@ impl fmt::Display for TryFromIntError {
2507
2507
macro_rules! try_from_unbounded {
2508
2508
( $source: ty, $( $target: ty) ,* ) => { $(
2509
2509
#[ unstable( feature = "try_from" , issue = "33417" ) ]
2510
- impl From <$source> for $target {
2510
+ impl TryFrom <$source> for $target {
2511
+ type Error = Infallible ;
2512
+
2511
2513
#[ inline]
2512
- fn from ( value: $source) -> $target {
2513
- value as $target
2514
+ fn try_from ( value: $source) -> Result < Self , Self :: Error > {
2515
+ Ok ( value as $target)
2514
2516
}
2515
2517
}
2516
2518
) * }
@@ -2617,7 +2619,7 @@ try_from_lower_bounded!(isize, usize);
2617
2619
#[ cfg( target_pointer_width = "16" ) ]
2618
2620
mod ptr_try_from_impls {
2619
2621
use super :: TryFromIntError ;
2620
- use convert:: TryFrom ;
2622
+ use convert:: { Infallible , TryFrom } ;
2621
2623
2622
2624
try_from_upper_bounded ! ( usize , u8 ) ;
2623
2625
try_from_unbounded ! ( usize , u16 , u32 , u64 , u128 ) ;
@@ -2643,7 +2645,7 @@ mod ptr_try_from_impls {
2643
2645
#[ cfg( target_pointer_width = "32" ) ]
2644
2646
mod ptr_try_from_impls {
2645
2647
use super :: TryFromIntError ;
2646
- use convert:: TryFrom ;
2648
+ use convert:: { Infallible , TryFrom } ;
2647
2649
2648
2650
try_from_upper_bounded ! ( usize , u8 , u16 ) ;
2649
2651
try_from_unbounded ! ( usize , u32 , u64 , u128 ) ;
@@ -2669,7 +2671,7 @@ mod ptr_try_from_impls {
2669
2671
#[ cfg( target_pointer_width = "64" ) ]
2670
2672
mod ptr_try_from_impls {
2671
2673
use super :: TryFromIntError ;
2672
- use convert:: TryFrom ;
2674
+ use convert:: { Infallible , TryFrom } ;
2673
2675
2674
2676
try_from_upper_bounded ! ( usize , u8 , u16 , u32 ) ;
2675
2677
try_from_unbounded ! ( usize , u64 , u128 ) ;
0 commit comments