-
Notifications
You must be signed in to change notification settings - Fork 13.4k
ICE: Existential type (w/ and w/o NLL) #53598
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Backtrace:
|
Hmm I reproduced same ICE with next snippet without #![feature(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)
}
}
#[derive(Default)]
pub struct Stub<E: Engine> {
_e: std::marker::PhantomData<E>
}
impl<E: Engine> Renderable<E> for Stub<E> {
fn render(&self, _eng: &E) {}
}
fn main() {
Div.build::<Stub<_>>(None);
} |
Smaller repro: #![feature(existential_type)]
pub trait Foo {
type Item: std::fmt::Debug;
fn foo<T: std::fmt::Debug>(_: T) -> Self::Item;
}
#[derive(Debug)]
pub struct S<T>(std::marker::PhantomData<T>);
pub struct S2;
impl Foo for S2 {
existential type Item: std::fmt::Debug;
fn foo<T: std::fmt::Debug>(_: T) -> Self::Item {
S::<T>(Default::default())
}
} Edit: AFAICT the problem is the existential assoc type is being made dependent on the type parameter of the trait method ( |
@Arnavion you example compiles without ICE. |
@Arnavion, sorry it needs to be added Here is complete one which fails to compile regardless #![feature(existential_type)]
pub trait Foo {
type Item: std::fmt::Debug;
fn foo<T: std::fmt::Debug>(_: T) -> Self::Item;
}
#[derive(Debug)]
pub struct S<T>(std::marker::PhantomData<T>);
pub struct S2;
impl Foo for S2 {
existential type Item: std::fmt::Debug;
fn foo<T: std::fmt::Debug>(_: T) -> Self::Item {
S::<T>(Default::default())
}
}
fn main() {
S2::foo(123);
} |
@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. |
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? |
Removed my assignment. Unfortunately I'm running behind on the not-time-critical issues I assigned to myself. |
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. |
This no longer produces an ICE on the latest nightly. |
Yes, it was fixed by #62090 |
Add tests for issue rust-lang#53598 and rust-lang#57700 Closes rust-lang#53598 and rust-lang#57700
Rollup of 10 pull requests Successful merges: - #62108 (Use sharded maps for queries) - #63297 (Improve pointer offset method docs) - #63306 (Adapt AddRetag for shallow retagging) - #63406 (Suggest using a qualified path in patterns with inconsistent bindings) - #63431 (Revert "Simplify MIR generation for logical ops") - #63449 (resolve: Remove remaining special cases from built-in macros) - #63461 (docs: add stdlib env::var(_os) panic) - #63473 (Regression test for #56870) - #63474 (Add tests for issue #53598 and #57700) - #63480 (Fixes #63477) Failed merges: r? @ghost
Add tests for issue rust-lang#53598 and rust-lang#57700 Closes rust-lang#53598 and rust-lang#57700
Rollup of 9 pull requests Successful merges: - #62108 (Use sharded maps for queries) - #63297 (Improve pointer offset method docs) - #63406 (Suggest using a qualified path in patterns with inconsistent bindings) - #63431 (Revert "Simplify MIR generation for logical ops") - #63449 (resolve: Remove remaining special cases from built-in macros) - #63461 (docs: add stdlib env::var(_os) panic) - #63473 (Regression test for #56870) - #63474 (Add tests for issue #53598 and #57700) - #63480 (Fixes #63477) Failed merges: r? @ghost
here is the example:
this example will compile well if you remove
nll
The text was updated successfully, but these errors were encountered: