Skip to content

ICE on self-referential typedef #62364

Closed
Closed
@imbrem

Description

@imbrem

So, while writing some really nasty code for an interpreter, I ended up with an overcomplicated version of this code:

use std::sync::Arc;

pub enum ThingOrRef<S> where S: AsRef<Self> {
    ThingRef(S),
    Thing
}

pub type ThingArena<'ctx, T> = ThingOrRef<Arc<Self>>;

(Playground link)

Alas, it leads to an ICE, with this message:

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 18446744073709551615'

I wonder how an unchecked overflow got in there (18446744073709551615 == -1)...

Funnily enough, if I remove the 'ctx or the T (or both) it compiles just fine, without error. But with both the ctx and T in, crash.

Metadata

Metadata

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions