Skip to content

Impl check with trait ICE #36052

Closed
Closed
@ebfull

Description

@ebfull
use std::marker::PhantomData;

struct Foo<T: Bar>(PhantomData<T>);

trait Bar: Sized {
    fn bar(n: usize) -> Foo<Self>;
}

struct A;
struct B;
impl Bar for A {
    fn bar(n: usize) -> Foo<A> {
        unimplemented!()
    }
}

impl Bar for B {
    fn bar(n: usize) -> Foo<A> { // should be Foo<B>
        unimplemented!()
    }
}

fn main() { }

causes on current nightly (rustc 1.13.0-nightly (3c5a0fa45 2016-08-22)):

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:326
stack backtrace:
   1:     0x7f282faa7c63 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:     0x7f282fab9d6c - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:     0x7f282fab7fe7 - std::panicking::default_hook::h9e30d428ee3b0c43
   4:     0x7f282fab87f8 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:     0x7f282fab8692 - std::panicking::begin_panic::hcb11a4dc6d779ae5
   6:     0x7f282fab85c0 - std::panicking::begin_panic_fmt::h310416c62f3935b3
   7:     0x7f282fab8541 - rust_begin_unwind
   8:     0x7f282fb23cff - core::panicking::panic_fmt::hc5789f4e80194729
   9:     0x7f282fb23c2b - core::panicking::panic::h1953378f4b37b561
  10:     0x7f282e1bdecc - rustc_typeck::check::compare_method::compare_impl_method::_{{closure}}::h08bef90d287aed42
  11:     0x7f282e119c99 - rustc_typeck::check::compare_method::compare_impl_method::he3538453c2efe177
  12:     0x7f282e12ec22 - rustc_typeck::check::check_impl_items_against_trait::hb105ca8bb42a0b3d
  13:     0x7f282e12c1a2 - rustc_typeck::check::check_item_type::hba3733559d49be1e
  14:     0x7f282e1249eb - _<rustc_typeck..check..CheckItemTypesVisitor<'a, 'tcx> as rustc..hir..intravisit..Visitor<'tcx>>::visit_item::h369cacffbaa18923
  15:     0x7f282e1268eb - rustc_typeck::check::check_item_types::h81e44a5d40f450fd
  16:     0x7f282e19e28d - rustc_typeck::check_crate::h8ec8b2f490f5dc28
  17:     0x7f282fea3a03 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
  18:     0x7f282fe6fb21 - rustc_driver::driver::phase_3_run_analysis_passes::hc0de40cea97d81a1
  19:     0x7f282fe5c146 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
  20:     0x7f282fe8f656 - rustc_driver::run_compiler::h184264500271cc39
  21:     0x7f282fdca8c2 - std::panicking::try::do_call::h17a7a17ad7240c5c
  22:     0x7f282fac80d6 - __rust_maybe_catch_panic
  23:     0x7f282fde42aa - _<F as alloc..boxed..FnBox<A>>::call_box::h93f9128277b2964a
  24:     0x7f282fab63b2 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
  25:     0x7f2827dbe453 - start_thread
  26:     0x7f282f7037de - __GI___clone
  27:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions