Closed

Description
Describe the Bug
I'm posting it here since it generates the code, but if you think it should be moved to the rustc repo, let me know.
If you have a big enough enum, the wasm-bdingen generated code causes rustc to stack overflow. This didn't happen in rustc 1.44.1, but does happen in 1.45.0.
Code:
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub enum Code {
A0,
A1,
A2,
A3,
A4,
A5,
...
A3997,
A3998,
A3999,
A4000,
}
Steps to Reproduce
# works
cargo +1.44.1 check
# stack overflow
cargo +1.45.0 check
Expected Behavior
It compiles
Actual Behavior
Stack overflow in rustc
Additional Context
Add any other context about the problem here.
It generates code like this:
pub enum Code
{
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16,
A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31,
A32, A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45, A46,
...
A3994, A3995, A3996, A3997, A3998, A3999, A4000,
} # [allow(clippy :: all)] impl wasm_bindgen :: convert :: IntoWasmAbi for
Code { type Abi = u32 ; # [inline] fn into_abi(self) -> u32 { self as u32 } }
# [allow(clippy :: all)] impl wasm_bindgen :: convert :: FromWasmAbi for Code
{
type Abi = u32 ; # [inline] unsafe fn from_abi(js : u32) -> Self
{
if js == Code :: A0 as u32 { Code :: A0 } else if js == Code :: A1 as
u32 { Code :: A1 } else if js == Code :: A2 as u32 { Code :: A2 } else
if js == Code :: A3 as u32 { Code :: A3 } else if js == Code :: A4 as
u32 { Code :: A4 } else if js == Code :: A5 as u32 { Code :: A5 } else
if js == Code :: A6 as u32 { Code :: A6 } else if js == Code :: A7 as
u32 { Code :: A7 } else if js == Code :: A8 as u32 { Code :: A8 } else
...
{ Code :: A3998 } else if js == Code :: A3999 as u32 { Code :: A3999 }
else if js == Code :: A4000 as u32 { Code :: A4000 } else
{ wasm_bindgen :: throw_str("invalid enum value passed") }
}
} # [allow(clippy :: all)] impl wasm_bindgen :: convert :: OptionFromWasmAbi
Crashes on Win10 and WSL. Didn't test any other OS.
The generated code could be turned into a simple transmute (IIRC, that's what the compiler will generate if it doesn't stack overflow)