Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum_derive cannot contain more than 24 variants due to recursion limit #12

Closed
kennytm opened this issue May 16, 2016 · 2 comments
Closed

Comments

@kennytm
Copy link

kennytm commented May 16, 2016

Test case:

custom_derive! {
    #[derive(Debug, PartialEq, EnumFromStr)]
    pub enum HugeEnum {
        Case0, Case1, Case2, Case3, Case4, Case5, Case6, Case7, Case8, Case9,
        Case10, Case11, Case12, Case13, Case14, Case15, Case16, Case17, Case18, Case19,
        Case20, Case21, Case22, Case23, Case24, Case25, Case26, Case27, Case28, Case29,
        Case30, Case31, Case32, Case33, Case34, Case35, Case36, Case37, Case38, Case39,
        Case40, Case41, Case42, Case43, Case44, Case45, Case46, Case47, Case48, Case49,
        Case50, Case51, Case52, Case53, Case54, Case55, Case56, Case57, Case58, Case59,
        Case60, Case61, Case62, Case63, Case64, Case65, Case66, Case67, Case68, Case69,
        Case70, Case71, Case72, Case73, Case74, Case75, Case76, Case77, Case78, Case79,
        Case80, Case81, Case82, Case83, Case84, Case85, Case86, Case87, Case88, Case89,
        Case90, Case91, Case92, Case93, Case94, Case95, Case96, Case97, Case98, Case99,
    }
}

In version 0.1.6, with Rust 1.8.0 – 1.10.0, this fails with:

<enum_derive macros>:17:1: 19:32 error: recursion limit reached while expanding the macro `enum_derive_util`
<enum_derive macros>:17 enum_derive_util ! {
                        ^

cc rust-lang/rust#22552

@DanielKeep
Copy link
Owner

Apologies for the long hiatus.

There's nothing I can do about this. I'd need either procedural macros (but I refuse to sacrifice working on stable) or for macro_rules! to learn how to do tail call optimisation.

You have to raise the recursion limit and hope you don't hit a more fundemental limit in the compiler (like blowing the actual call stack).

@lambda-fairy
Copy link

For anyone else who runs across this issue, the workaround is to add

#![recursion_limit = "1000"]

to the top of your crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants