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
Assignees
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-needs-test Call 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)]` 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

@Seeker14491
Copy link
Contributor

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.
@zackmdavis zackmdavis added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 8, 2018
@eddyb
Copy link
Member

eddyb commented Nov 22, 2018

cc @nikomatsakis @Zoxc @cramertj

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

oli-obk commented Mar 12, 2019

related to #53678

both seem to not fully resolve all associated types

@Aaron1011
Copy link
Member

This compiles successfully on the latest nightly.

@Centril Centril added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. requires-nightly This issue requires a nightly compiler in some way. A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. labels Jul 28, 2019
@cramertj cramertj added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 29, 2019
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

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

@Seeker14491
Copy link
Contributor Author

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

@lcnr
Copy link
Contributor

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.

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

See also this short discussion on Zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-needs-test Call 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)]` 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

9 participants