File tree 3 files changed +15
-5
lines changed
3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -467,7 +467,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
467
467
// with an uninhabited error type.
468
468
#[ unstable( feature = "try_from" , issue = "33417" ) ]
469
469
impl < T , U > TryFrom < U > for T where U : Into < T > {
470
- type Error = ! ;
470
+ type Error = Infallible ;
471
471
472
472
fn try_from ( value : U ) -> Result < Self , Self :: Error > {
473
473
Ok ( U :: into ( value) )
Original file line number Diff line number Diff line change 2
2
3
3
#![ stable( feature = "rust1" , since = "1.0.0" ) ]
4
4
5
- use convert:: TryFrom ;
5
+ use convert:: { TryFrom , Infallible } ;
6
6
use fmt;
7
7
use intrinsics;
8
8
use mem;
@@ -4531,9 +4531,19 @@ impl fmt::Display for TryFromIntError {
4531
4531
}
4532
4532
4533
4533
#[ unstable( feature = "try_from" , issue = "33417" ) ]
4534
+ impl From < Infallible > for TryFromIntError {
4535
+ fn from ( x : Infallible ) -> TryFromIntError {
4536
+ match x { }
4537
+ }
4538
+ }
4539
+
4540
+ #[ unstable( feature = "never_type" , issue = "35121" ) ]
4534
4541
impl From < !> for TryFromIntError {
4535
4542
fn from ( never : !) -> TryFromIntError {
4536
- never
4543
+ // Match rather than coerce to make sure that code like
4544
+ // `From<Infallible> for TryFromIntError` above will keep working
4545
+ // when `Infallible` becomes an alias to `!`.
4546
+ match never { }
4537
4547
}
4538
4548
}
4539
4549
Original file line number Diff line number Diff line change 6
6
7
7
#![ feature( try_from, never_type) ]
8
8
9
- use std:: convert:: TryInto ;
9
+ use std:: convert:: { TryInto , Infallible } ;
10
10
11
11
struct Foo < T > {
12
12
t : T ,
@@ -32,6 +32,6 @@ impl<T> Into<Vec<T>> for Foo<T> {
32
32
}
33
33
34
34
pub fn main ( ) {
35
- let _: Result < Vec < i32 > , ! > = Foo { t : 10 } . try_into ( ) ;
35
+ let _: Result < Vec < i32 > , Infallible > = Foo { t : 10 } . try_into ( ) ;
36
36
}
37
37
You can’t perform that action at this time.
0 commit comments