Skip to content

ICE in existential type with lifetime in trait implementation #54169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
petertodd opened this issue Sep 13, 2018 · 2 comments
Closed

ICE in existential type with lifetime in trait implementation #54169

petertodd opened this issue Sep 13, 2018 · 2 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@petertodd
Copy link
Contributor

Example:

#![feature(existential_type)]
use std::fmt::Debug;

pub trait Foo {
    type Assoc : Debug;
    fn func() -> Self::Assoc;
}

pub struct Bar;

impl Foo for Bar {
    existential type Assoc<'b> : Debug;

    fn func() -> Self::Assoc {
    }   
}

fn main() {
}

Backtrace:

$ rustc  existential-panic.rs 
error: internal compiler error: librustc/ty/subst.rs:445: Region parameter out of range when substituting in region 'b (root type=Some(Assoc::<'b>)) (index=0)

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:525:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
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.30.0-nightly (2f1547c0a 2018-09-11) running on x86_64-unknown-linux-gnu
@zackmdavis zackmdavis added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 13, 2018
@jonas-schievink jonas-schievink added A-associated-items Area: Associated items (types, constants & functions) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 2, 2019
@Matthias247
Copy link
Contributor

I just run into the same problem when trying to define an async interface (with Future) and implement it with existential type:

#![feature(existential_type, async_await)]

use std::future::Future;

pub trait MyTrait<'a> {
    type ResultFut: Future<Output = ()> + 'a;

    fn do_sth(&'a mut self, a: &'a str) -> Self::ResultFut;
}

struct MyImpl {
}

impl<'a> MyTrait<'a> for MyImpl {
    existential type ResultFut<'a>: Future<Output = ()> + 'a;

    fn do_sth(&'a mut self, a: &'a str) -> Self::ResultFut {
        async {
            Ok(())
        }
    }
}
Compiling playground v0.0.1 (/playground)
error: internal compiler error: src/librustc/ty/subst.rs:489: Region parameter out of range when substituting in region 'a (root type=Some(ResultFut::<'a, 'a>)) (index=1)

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:572:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
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.36.0-nightly (a9ec99f42 2019-05-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@Centril Centril added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` F-async_await requires-nightly This issue requires a nightly compiler in some way. labels Jul 28, 2019
@petertodd
Copy link
Contributor Author

Closing as existential_type no longer exists and the replacement type_alias_impl_trait doesn't seem to have a similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

No branches or pull requests

5 participants