Closed DutchGhost closed 5 years ago
Confirmed this is still reproducible as of latest nightly (rustc 1.36.0-nightly (00859e3e6 2019-04-29))
This is about as small as I can get it to repro:
#![feature(async_await, existential_type)]
pub trait Bar
{
type E: Copy;
fn foo<T>() -> Self::E;
}
impl <S> Bar for S
{
existential type E: Copy;
fn foo<T>() -> Self::E
{
async {}
}
}
fn main() {}
Marking as blocking -- thanks for the minimal reproduction @gilescope, that's fantastic!
@rustbot claim
Going to investigate this with @nikomatsakis, see this message.
Not really related to async-await. This minimization does not involve async/await but gets a very similar ICE:
#![feature(existential_type)]
pub trait Bar
{
type E: Copy;
fn foo<T>() -> Self::E;
}
impl <S> Bar for S
{
existential type E: Copy;
fn foo<T>() -> Self::E
{
|| ()
}
}
fn main() {}
Preferred minimization (no annoying closures):
#![feature(existential_type)]
pub trait Bar
{
type E: Copy;
fn foo<T>() -> Self::E;
}
impl <S: Default> Bar for S
{
existential type E: Copy;
fn foo<T: Default>() -> Self::E
{
(S::default(), T::default())
}
}
fn main() {}
The problem here is that the inferred type for E
needs to be (S, T)
, but T
is not in scope there. So we expect an error. (Not an ICE)
The Zulip thread diagnoses the problem and explains everything in a lot of detail.
Playing with async/await, using
and some nightly features, I stumbled upon this ICE. (possibly related to https://github.com/rust-lang/rust/issues/55265)
Backtrace:
``` error: internal compiler error: librustc\ty\subst.rs:462: Type parameter `W/#1` (W/1) out of range when substituting (root type=Some(impl futures::Future)) substs=[S] thread 'main' panicked at 'Box::start_sip` end of query stack error: aborting due to previous error note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.31.0-nightly (de9666f12 2018-10-31) running on x86_64-pc-windows-msvc note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin note: some of the compiler flags provided by cargo are hidden error: Could not compile `webscraper_better`. ```No ICE happens when writing the trait and implementation like this (notice the Generic parameters are now on the trait definition rather than on the function):