Skip to content

ICE: rustc overflows its stack on instanciation of enum #25693

Closed
@abandoned-cocoon

Description

@abandoned-cocoon

Also available at http://is.gd/7glmKz

pub trait Paramters { type SelfRef; }

struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> }
struct BP;

impl<'a> Paramters for RP<'a> { type SelfRef = &'a X<RP<'a>>; }
impl Paramters for BP { type SelfRef = Box<X<BP>>; }

pub struct Y;
pub enum X<P: Paramters> {
    Nothing,
    SameAgain(P::SelfRef, Y)
}

fn main() {
    // fine
    let bnil: Box<X<BP>> = Box::new(X::Nothing);
    let bx: Box<X<BP>> = Box::new(X::SameAgain(bnil, Y));
    // crashes rustc
    let rnil: X<RP> = X::Nothing;
    let rx: X<RP> = X::SameAgain(&rnil, Y);
}

Output:

thread 'rustc' has overflowed its stack
Illegal instruction (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions