]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/issue-66787.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / src / test / ui / consts / issue-66787.rs
1 // build-pass
2 // compile-flags: --crate-type lib
3
4 // Regression test for ICE which occurred when const propagating an enum with three variants
5 // one of which is uninhabited.
6
7 pub enum ApiError {}
8 #[allow(dead_code)]
9 pub struct TokioError {
10 b: bool,
11 }
12 pub enum Error {
13 Api {
14 source: ApiError,
15 },
16 Ethereum,
17 Tokio {
18 source: TokioError,
19 },
20 }
21 struct Api;
22 impl IntoError<Error> for Api
23 {
24 type Source = ApiError;
25 fn into_error(self, error: Self::Source) -> Error {
26 Error::Api {
27 source: (|v| v)(error),
28 }
29 }
30 }
31
32 pub trait IntoError<E>
33 {
34 /// The underlying error
35 type Source;
36
37 /// Combine the information to produce the error
38 fn into_error(self, source: Self::Source) -> E;
39 }