Skip to content

Weird stack overflow issue with single struct #1467

Closed
@kardeiz

Description

@kardeiz

When I run the following code:

#[derive(Debug)]
pub struct Foo {
    baz: i32
}

impl serde::Serialize for Foo {
    fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        #[derive(serde_derive :: Serialize)]
        struct Inner<'a>(&'a i32);
        let inner = Inner(&self.baz);
        serde::Serialize::serialize(&inner, serializer)
    }
}

// #[derive(serde_derive::Serialize)]
// pub struct Bar {
//     baz: i32
// }

fn main() {}

I get

thread 'main' has overflowed its stack
fatal runtime error: stack overflow

However, if I uncomment the Bar struct, it runs just fine.

This is with serde 1.0.85. It doesn't seem to be the same as the other open SO issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions