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; into_error(self, error: Self::Source) -> Error25 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 into_error(self, source: Self::Source) -> E38 fn into_error(self, source: Self::Source) -> E; 39 } 40