Skip to content

Commit e822235

Browse files
committed
add a test
1 parent 8655ad5 commit e822235

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
}

0 commit comments

Comments
 (0)