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 due to missing associated type in trait implementation #20347

Closed
japaric opened this issue Dec 30, 2014 · 6 comments
Closed

ICE due to missing associated type in trait implementation #20347

japaric opened this issue Dec 30, 2014 · 6 comments
Assignees
Labels
A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@japaric
Copy link
Member

japaric commented Dec 30, 2014

STR

Didn't have time to write a shorter snippet

#![crate_type = "lib"]
#![feature(associated_types, lang_items, unboxed_closures)]
#![no_std]

use Option::{None, Some};

trait Iterator {
    type Item;

    fn next(&mut self) -> Option<Self::Item>;
}

trait DoubleEndedIterator: Iterator {
    fn next_back(&mut self) -> Option< <Self as Iterator>::Item>;
}

struct Rev<I>(I);

impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
    // forgot this!
    //type Item = <I as Iterator>::Item;

    fn next(&mut self) -> Option< <I as Iterator>::Item> {
        self.0.next_back()
    }
}

#[lang = "copy"] trait Copy {}
#[lang = "sized"] trait Sized {}

enum Option<T> {
    None,
    Some(T),
}

#[lang = "fn_mut"]
trait FnMut<Args, Result> {
    extern "rust-call" fn call_mut(&mut self, Args) -> Result;
}

Output

iter.rs:23:5: 25:6 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 38 }:Rev<I>.Iterator, substs=Substs[types=[[_];[];[]], regions=[[];[];[]]], nested=[[Obligation(predicate=Binder(TraitPredicate(TraitRef(I, Sized))),depth=1), Obligation(predicate=Binder(TraitPredicate(TraitRef(I, DoubleEndedIterator))),depth=1)];[];[]])` did not contain projection for `Obligation(predicate=<Rev<I> as TraitRef(Rev<I>, Iterator)>::Item,depth=0)`
iter.rs:23     fn next(&mut self) -> Option< <I as Iterator>::Item> {
iter.rs:24         self.0.next_back()
iter.rs:25     }
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /root/rust/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7fddb1e70120 - sys::backtrace::write::h3fe61c98bf398fe8P8s
   2:     0x7fddb1e8fef0 - failure::on_fail::h55da319a91ee267cEpz
   3:     0x7fddb1e05b40 - rt::unwind::begin_unwind_inner::h2a51826b093fcd9eJ3y
   4:     0x7fddad24b3d0 - rt::unwind::begin_unwind::h3298842058425057001
   5:     0x7fddad24b360 - diagnostic::SpanHandler::span_bug::heeaf2edd6daa003fNQF
   6:     0x7fddb022acb0 - middle::traits::project::project_type::hcf50d7eec736df9c35P
   7:     0x7fddb0222800 - middle::traits::fulfill::process_predicate::h3703aabc133e79cayGP
   8:     0x7fddb0221ab0 - middle::traits::fulfill::FulfillmentContext<$u{27}tcx$GT$::select::h827e4d042486e566SzP
   9:     0x7fddb00ee7c0 - middle::traits::fulfill::FulfillmentContext<$u{27}tcx$GT$::select_all_or_error::heebbe09eddbd26dfDwP
  10:     0x7fddb1510cd0 - check::compare_impl_method::h359a8a44e8f8def4Zfk
  11:     0x7fddb14ff0b0 - check::check_item::hfedb86714512d4d8XRj
  12:     0x7fddb169d450 - check_crate::unboxed_closure.39783
  13:     0x7fddb16981f0 - check_crate::h7446c5344d10b3c1cGx
  14:     0x7fddb23a98d0 - driver::phase_3_run_analysis_passes::hb59d2d67157ec124gva
  15:     0x7fddb2397fb0 - driver::compile_input::hff9e8d16e3108315vba
  16:     0x7fddb24e4900 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h10803646332669730367
  17:     0x7fddb24e36c0 - rt::unwind::try::try_fn::h3820096971255462672
  18:     0x7fddb1ef4eb0 - rust_try_inner
  19:     0x7fddb1ef4ea0 - rust_try
  20:     0x7fddb24e3a10 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h15250775183210022334
  21:     0x7fddb1e7f8d0 - sys::thread::thread_start::h7b82ef93cab3e580K1v
  22:     0x7fddaca690c0 - start_thread
  23:     0x7fddb1aab2d9 - __clone
  24:                0x0 - <unknown>

Version

84f5ad8

cc @nikomatsakis

@nikomatsakis
Copy link
Contributor

The fix here is just to remove that assert and instead generate a ty::ty_err, I think. We can rely on other phases of the compiler to generate a suitable error.

@nikomatsakis
Copy link
Contributor

Adding to 1.0 alpha milestone. This is something people hit a lot.

@nrc nrc self-assigned this Jan 6, 2015
@nrc
Copy link
Member

nrc commented Jan 6, 2015

This seems to be fixed, when running the above snippet, I get "not all trait items implemented, missing: Item [E0046]"

@nikomatsakis
Copy link
Contributor

And yet people keep hitting ICEs? Maybe some of the other examples cause trouble?

@nikomatsakis
Copy link
Contributor

But I can't reproduce it either. Maybe they're just using older compilers?

@nikomatsakis
Copy link
Contributor

Ah, no, reading the code, I see I landed a patch for this. Argh. Sorry, so much going on I just forgot.

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) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants