File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -C opt-level=0
2
+ #![ crate_type = "lib" ]
3
+
4
+ pub enum ApiError { }
5
+ #[ allow( dead_code) ]
6
+ pub struct TokioError {
7
+ b : bool ,
8
+ }
9
+ pub enum Error {
10
+ Api {
11
+ source : ApiError ,
12
+ } ,
13
+ Ethereum ,
14
+ Tokio {
15
+ source : TokioError ,
16
+ } ,
17
+ }
18
+ struct Api ;
19
+ impl IntoError < Error > for Api
20
+ {
21
+ type Source = ApiError ;
22
+ // CHECK-LABEL: @into_error
23
+ // CHECK: unreachable
24
+ // Also check the next two instructions to make sure we do not match against `unreachable`
25
+ // elsewhere in the code (e.g., in the closure bode).
26
+ // CHECK-NEXT: load
27
+ // CHECK-NEXT: ret
28
+ #[ no_mangle]
29
+ fn into_error ( self , error : Self :: Source ) -> Error {
30
+ Error :: Api {
31
+ source : ( |v| v) ( error) ,
32
+ }
33
+ }
34
+ }
35
+
36
+ pub trait IntoError < E >
37
+ {
38
+ /// The underlying error
39
+ type Source ;
40
+
41
+ /// Combine the information to produce the error
42
+ fn into_error ( self , source : Self :: Source ) -> E ;
43
+ }
You can’t perform that action at this time.
0 commit comments