Skip to content

ICE: Existential type (w/ and w/o NLL) #53598

@andreytkachenko

Description

@andreytkachenko

here is the example:

#![feature(nll, existential_type)] pub trait Engine {} pub trait RenderImplementation<E, CE> where E: Engine, CE: Engine, { fn render_impl<C: Renderable<CE>>(&self, eng: &E, children: &C); } pub trait Renderable<E> where E: Engine, { fn render(&self, eng: &E); } pub trait View<E, CE> where E: Engine, CE: Engine, { type Renderable: Renderable<E>; fn build<C: Renderable<CE> + 'static>(self, children: Option<C>) -> Self::Renderable; } pub struct Node <E, I, CHE, CH> where E: Engine, CHE: Engine, I: RenderImplementation<E, CHE>, CH: Renderable<CHE> { _m: std::marker::PhantomData<(I, CH, E, CHE)> } impl<E, I, CHE, CH> Node<E, I, CHE, CH> where E: Engine, CHE: Engine, I: RenderImplementation<E, CHE>, CH: Renderable<CHE> { pub fn new(_item: I, _children: CH) -> Self { Self { _m: Default::default() } } } impl<E, I, CHE, CH> Renderable<E> for Node<E, I, CHE, CH> where E: Engine, CHE: Engine, I: RenderImplementation<E, CHE>, CH: Renderable<CHE> { fn render(&self, _eng: &E) {} } impl <E: Engine, T: Renderable<E>> Renderable<E> for Option<T> { fn render(&self, _eng: &E) {} } pub struct HtmlEngine; impl Engine for HtmlEngine {} pub struct Div; impl RenderImplementation<HtmlEngine, HtmlEngine> for Div { fn render_impl<C>(&self, _eng: &HtmlEngine, _children: &C) where C: Renderable<HtmlEngine> {} } impl View<HtmlEngine, HtmlEngine> for Div { existential type Renderable: Renderable<HtmlEngine>; fn build<C: Renderable<HtmlEngine> + 'static>(self, children: Option<C>) -> Self::Renderable { Node::new(self, children) } } fn main() {}

this example will compile well if you remove nll

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions