Skip to content

ICE with existential associated type #54899

Description

@Seeker14491

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.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant 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.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions