@@ -2140,16 +2140,6 @@ impl Termination for () {
21402140 }
21412141}
21422142
2143- #[ stable( feature = "termination_trait_lib" , since = "1.61.0" ) ]
2144- impl < E : fmt:: Debug > Termination for Result < ( ) , E > {
2145- fn report ( self ) -> ExitCode {
2146- match self {
2147- Ok ( ( ) ) => ( ) . report ( ) ,
2148- Err ( err) => Err :: < !, _ > ( err) . report ( ) ,
2149- }
2150- }
2151- }
2152-
21532143#[ stable( feature = "termination_trait_lib" , since = "1.61.0" ) ]
21542144impl Termination for ! {
21552145 fn report ( self ) -> ExitCode {
@@ -2158,28 +2148,31 @@ impl Termination for ! {
21582148}
21592149
21602150#[ stable( feature = "termination_trait_lib" , since = "1.61.0" ) ]
2161- impl < E : fmt :: Debug > Termination for Result < ! , E > {
2151+ impl Termination for Infallible {
21622152 fn report ( self ) -> ExitCode {
2163- let Err ( err) = self ;
2164- // Ignore error if the write fails, for example because stderr is
2165- // already closed. There is not much point panicking at this point.
2166- let _ = writeln ! ( io:: stderr( ) , "Error: {err:?}" ) ;
2167- ExitCode :: FAILURE
2153+ match self { }
21682154 }
21692155}
21702156
21712157#[ stable( feature = "termination_trait_lib" , since = "1.61.0" ) ]
2172- impl < E : fmt:: Debug > Termination for Result < Infallible , E > {
2158+ impl Termination for ExitCode {
2159+ #[ inline]
21732160 fn report ( self ) -> ExitCode {
2174- let Err ( err) = self ;
2175- Err :: < !, _ > ( err) . report ( )
2161+ self
21762162 }
21772163}
21782164
21792165#[ stable( feature = "termination_trait_lib" , since = "1.61.0" ) ]
2180- impl Termination for ExitCode {
2181- #[ inline]
2166+ impl < T : Termination , E : fmt:: Debug > Termination for Result < T , E > {
21822167 fn report ( self ) -> ExitCode {
2183- self
2168+ match self {
2169+ Ok ( val) => val. report ( ) ,
2170+ Err ( err) => {
2171+ // Ignore error if the write fails, for example because stderr is
2172+ // already closed. There is not much point panicking at this point.
2173+ let _ = writeln ! ( io:: stderr( ) , "Error: {err:?}" ) ;
2174+ ExitCode :: FAILURE
2175+ }
2176+ }
21842177 }
21852178}
0 commit comments