]> git.proxmox.com Git - rustc.git/blob - tests/codegen/set-discriminant-invalid.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / codegen / set-discriminant-invalid.rs
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: llvm.trap()
24 // Also check the next two instructions to make sure we do not match against `trap`
25 // elsewhere in the code.
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: 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 }