File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 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>
467467// with an uninhabited error type.
468468#[ unstable( feature = "try_from" , issue = "33417" ) ]
469469impl < T , U > TryFrom < U > for T where U : Into < T > {
470- type Error = ! ;
470+ type Error = Infallible ;
471471
472472 fn try_from ( value : U ) -> Result < Self , Self :: Error > {
473473 Ok ( U :: into ( value) )
Original file line number Diff line number Diff line change 22
33#![ stable( feature = "rust1" , since = "1.0.0" ) ]
44
5- use convert:: TryFrom ;
5+ use convert:: { TryFrom , Infallible } ;
66use fmt;
77use intrinsics;
88use mem;
@@ -4531,9 +4531,19 @@ impl fmt::Display for TryFromIntError {
45314531}
45324532
45334533#[ 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" ) ]
45344541impl From < !> for TryFromIntError {
45354542 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 { }
45374547 }
45384548}
45394549
Original file line number Diff line number Diff line change 66
77#![ feature( try_from, never_type) ]
88
9- use std:: convert:: TryInto ;
9+ use std:: convert:: { TryInto , Infallible } ;
1010
1111struct Foo < T > {
1212 t : T ,
@@ -32,6 +32,6 @@ impl<T> Into<Vec<T>> for Foo<T> {
3232}
3333
3434pub fn main ( ) {
35- let _: Result < Vec < i32 > , ! > = Foo { t : 10 } . try_into ( ) ;
35+ let _: Result < Vec < i32 > , Infallible > = Foo { t : 10 } . try_into ( ) ;
3636}
3737
You can’t perform that action at this time.
0 commit comments