11//@ run-pass
22
33#![ feature( try_trait_v2) ]
4+ #![ feature( try_trait_v2_residual) ]
45
5- use std:: ops:: { ControlFlow , FromResidual , Try } ;
6+ use std:: ops:: { ControlFlow , FromResidual , Residual , Try } ;
67
78enum MyResult < T , U > {
89 Awesome ( T ) ,
9- Terrible ( U )
10+ Terrible ( U ) ,
1011}
1112
1213enum Never { }
@@ -27,25 +28,38 @@ impl<U, V> Try for MyResult<U, V> {
2728 }
2829}
2930
30- impl < U , V , W > FromResidual < MyResult < Never , V > > for MyResult < U , W > where V : Into < W > {
31+ impl < U , V , W > FromResidual < MyResult < Never , V > > for MyResult < U , W >
32+ where
33+ V : Into < W > ,
34+ {
3135 fn from_residual ( x : MyResult < Never , V > ) -> Self {
3236 match x {
3337 MyResult :: Terrible ( e) => MyResult :: Terrible ( e. into ( ) ) ,
3438 }
3539 }
3640}
3741
42+ impl < U , V > Residual < U > for MyResult < Never , V > {
43+ type TryType = MyResult < U , V > ;
44+ }
45+
3846type ResultResidual < E > = Result < std:: convert:: Infallible , E > ;
3947
40- impl < U , V , W > FromResidual < ResultResidual < V > > for MyResult < U , W > where V : Into < W > {
48+ impl < U , V , W > FromResidual < ResultResidual < V > > for MyResult < U , W >
49+ where
50+ V : Into < W > ,
51+ {
4152 fn from_residual ( x : ResultResidual < V > ) -> Self {
4253 match x {
4354 Err ( e) => MyResult :: Terrible ( e. into ( ) ) ,
4455 }
4556 }
4657}
4758
48- impl < U , V , W > FromResidual < MyResult < Never , V > > for Result < U , W > where V : Into < W > {
59+ impl < U , V , W > FromResidual < MyResult < Never , V > > for Result < U , W >
60+ where
61+ V : Into < W > ,
62+ {
4963 fn from_residual ( x : MyResult < Never , V > ) -> Self {
5064 match x {
5165 MyResult :: Terrible ( e) => Err ( e. into ( ) ) ,
0 commit comments