Repository navigation
ICE: Existential type (w/ and w/o NLL) #53598
Copy link
Copy link
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Projects
- StatusShow more project fieldsDone
Activity
matthiaskrgr commentedon Aug 22, 2018
Backtrace:
andreytkachenko commentedon Aug 22, 2018
Hmm I reproduced same ICE with next snippet without
nll:[-]ICE: Existential type + NLL [/-][+]ICE: Existential type [+ NLL] [/+][-]ICE: Existential type [+ NLL] [/-][+]ICE: Existential type (w/ and w/o NLL)[/+]Arnavion commentedon Jan 29, 2019
Smaller repro:
Edit: AFAICT the problem is the existential assoc type is being made dependent on the type parameter of the trait method (
<S2 as Foo>::foo'sTin this repro,<Div as View<HtmlEngine, HtmlEngine>>::build'sCin the OP). So it would be a compile error if it weren't for the ICE.andreytkachenko commentedon Jan 29, 2019
@Arnavion you example compiles without ICE.
andreytkachenko commentedon Jan 29, 2019
@Arnavion, sorry it needs to be added
nllfeature or used 2018 edition.Here is complete one which fails to compile regardless
nllfeature:Arnavion commentedon Jan 29, 2019
@andreytkachenko Right, 2015 doesn't hit the error until you actually try to use the type.
Regardless, as I said in my previous comment, this code should be a compile error anyway regardless of edition, since it's trying to declare an associated type that depends on the type parameters of the trait method rather than the trait.
pnkfelix commentedon Mar 6, 2019
hey @oli-obk, have you had a chance to look into this yet? Do you think you will be looking at it in the near term, or should we unassign you?
3 remaining items
pnkfelix commentedon Mar 14, 2019
Discussed in T-compiler meeting. This is a blocker for the existential type feature. But there is no schedule yet set for stabilizing that feature. Thus, downgrading fixing this to P-medium.
Aaron1011 commentedon Jul 29, 2019
This no longer produces an ICE on the latest nightly.
Arnavion commentedon Jul 29, 2019
Yes, it was fixed by #62090
Rollup merge of rust-lang#63474 - adamAndMath:master, r=Centril
Auto merge of #63482 - Centril:rollup-iyakgmg, r=Centril
Rollup merge of rust-lang#63474 - adamAndMath:master, r=Centril
Auto merge of #63489 - Centril:rollup-uuf6z1s, r=Centril