Skip to content

thread 'rustc' has overflowed its stack (when using #[derive(serde::Deserialize)] inside a custom Deserialize impl) #81844

Closed
@moxian

Description

@moxian

Code

struct AB {}

impl<'de> serde::Deserialize<'de> for AB {
    fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        #[derive(serde::Deserialize)]  // comment this out to fix the stack overflow
        struct A2 {}
        
        return Ok(AB{})
    }
}

fn main(){}

playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8bfc3b0d3b728b256df33a4db645302c

Meta

rustc --version --verbose:

rustc 1.50.0-beta.5 (ff5998292 2021-01-05)
binary: rustc
commit-hash: ff59982926d98c8508008f0559f8a055260ac05e
commit-date: 2021-01-05
host: x86_64-pc-windows-msvc
release: 1.50.0-beta.5

(but also present in stable and nightly)

Error output

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: could not compile `playground`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions