Skip to content
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

ICE with existential associated type #54899

Closed
Seeker14491 opened this issue Oct 8, 2018 · 7 comments
Closed

ICE with existential associated type #54899

Seeker14491 opened this issue Oct 8, 2018 · 7 comments

Comments

@Seeker14491
Copy link
Contributor

@Seeker14491 Seeker14491 commented Oct 8, 2018

The following code causes an ICE:

#![feature(existential_type)]

extern crate futures; // 0.1.24

use futures::{future, Future};

pub struct AStruct;

pub trait ATrait {
    type FutureType: Future<Item = (), Error = Self::Error> + Send + 'static;
    type Error;

    fn a_function(&self) -> Self::FutureType;
}

impl ATrait for AStruct {
    existential type FutureType: Future<Item = (), Error = Self::Error> + Send;
    type Error = ();

    fn a_function(&self) -> Self::FutureType {
        future::ok(())
    }
}

Playground

Compiler output:

error: internal compiler error: broken MIR in DefId(0/0:14 ~ frontend[2c69]::{{impl}}[0]::a_function[0]) (Terminator { source_info: SourceInfo { span: src\lib.rs:19:9: 19:23, scope: scope[0] }, kind: _0 = const futures::future::result_::ok(move _2) -> [return: bb2, unwind: bb1] }): call dest mismatch (futures::future::result_::FutureResult<(), <AStruct as ATrait>::Error> <- futures::future::result_::FutureResult<(), ()>): NoSolution
  --> src\lib.rs:19:20
   |
19 |         future::ok(())
   |                    ^^

thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', librustc_errors\lib.rs:334:17
stack backtrace:
   0: <std::sync::barrier::BarrierWaitResult as core::fmt::Debug>::fmt
   1: <std::path::Iter<'a> as core::convert::AsRef<std::path::Path>>::as_ref
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
   5: std::panicking::rust_panic_with_hook
   6: <rustc_errors::emitter::ColorConfig as core::fmt::Debug>::fmt
   7: <rustc_errors::Handler as core::ops::drop::Drop>::drop
   8: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_impl_item
   9: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  10: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  11: rustc_driver::target_features::add_configuration
  12: _rust_maybe_catch_panic
  13: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  14: rustc_driver::main
  15: <unknown>
  16: std::panicking::update_panic_count
  17: _rust_maybe_catch_panic
  18: std::rt::lang_start_internal
  19: <unknown>
  20: <unknown>
  21: BaseThreadInitThunk
  22: RtlUserThreadStart
query stack during panic:
end of query stack

error: internal compiler error: unexpected panic

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 (4efdc04a5 2018-10-06) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

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

error: Could not compile `frontend`.

To learn more, run the command again with --verbose.
@eddyb
Copy link
Member

@eddyb eddyb commented Nov 22, 2018

Loading

@oli-obk oli-obk self-assigned this Jan 25, 2019
@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 12, 2019

related to #53678

both seem to not fully resolve all associated types

Loading

@Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Jul 28, 2019

This compiles successfully on the latest nightly.

Loading

Centril added a commit to Centril/rust that referenced this issue Jul 29, 2019
… r=varkor

Add tests for some `existential_type` ICEs

Fix rust-lang#53678
Fix rust-lang#60407
Fix rust-lang#60564

rust-lang#54899 will need some minimization before it can be added.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Jul 30, 2019
… r=varkor

Add tests for some `existential_type` ICEs

Fix rust-lang#53678
Fix rust-lang#60407
Fix rust-lang#60564

rust-lang#54899 will need some minimization before it can be added.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Jul 30, 2019
… r=varkor

Add tests for some `existential_type` ICEs

Fix rust-lang#53678
Fix rust-lang#60407
Fix rust-lang#60564

rust-lang#54899 will need some minimization before it can be added.

r? @varkor
@Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Nov 16, 2019

Can this be closed now that a test has been added?

Loading

@Seeker14491
Copy link
Contributor Author

@Seeker14491 Seeker14491 commented Nov 16, 2019

I don't believe a test has been added. Centril's commit above added tests for some related ICEs, but not this one.

Loading

@lcnr
Copy link
Contributor

@lcnr lcnr commented Sep 14, 2020

Considering that this issue used existential type and impl Trait has changed a lot since then I don't think trying to get an MVCE is worth it here, so I will close this without adding a regression test for this.

Loading

@lcnr lcnr closed this Sep 14, 2020
@vandenheuvel
Copy link
Contributor

@vandenheuvel vandenheuvel commented Sep 14, 2020

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants