Closed
Description
use std::marker::PhantomData;
pub trait Filterable {
type Filter;
}
pub trait ComponentMapper {
type Component;
fn entities_filtered(&self, <Self::Component as Filterable>::Filter)
where Self::Component: Filterable;
}
pub struct VecMapper<T> {
_marker: ::std::marker::PhantomData<T>
}
impl<T> VecMapper<T> {
pub fn new() -> VecMapper<T> {
VecMapper { _marker: PhantomData }
}
}
impl<T> ComponentMapper for VecMapper<T> {
type Component = T;
fn entities_filtered(&self, _filter: T::Filter) where T: Filterable {}
}
fn main() {
let _m: &ComponentMapper<Component=()> = &VecMapper::<()>::new();
}
Error message and backtrace:
src/lib.rs:1:1: 1:1 error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<() as Filterable>)),depth=0),Unimplemented)]` fulfilling during trans
src/lib.rs:1 use std::marker::PhantomData;
^
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
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176
stack backtrace:
1: 0x7fc6bff26e59 - sys::backtrace::write::h6cef21c2739be89enbs
2: 0x7fc6bff2eca6 - panicking::on_panic::hc7719c42798f79557bx
3: 0x7fc6bfef4d8e - rt::unwind::begin_unwind_inner::h1f260ccb571cc205LEw
4: 0x7fc6bcede5a7 - rt::unwind::begin_unwind::h10655059149932040525
5: 0x7fc6bcede566 - diagnostic::SpanHandler::span_bug::h418d05ddae4888f6u0A
6: 0x7fc6bddc0093 - session::Session::span_bug::he61831a7b1a0d90dX4v
7: 0x7fc6bf6454c8 - trans::monomorphize::normalize_associated_type::h2725703829457067863
8: 0x7fc6bf696cd4 - trans::monomorphize::monomorphic_fn::hf2ca16370d279d38YOM
9: 0x7fc6bf686fde - trans::callee::trans_fn_ref_with_substs::h855cd08e84e1dcecrRo
10: 0x7fc6bf76eebe - trans::meth::emit_vtable_methods::closure.57489
11: 0x7fc6bf76e717 - vec::Vec<T>.FromIterator<T>::from_iter::h56270794109279346
12: 0x7fc6bf76ca3e - trans::meth::get_vtable::closure.57435
13: 0x7fc6bf76e142 - iter::FlatMap<I, U, F>.Iterator::next::h12876249173377246673
14: 0x7fc6bf76e340 - vec::Vec<T>::extend_desugared::h1051564765688794204
15: 0x7fc6bf76d493 - iter::Iterator::collect::h11535940037352979281
16: 0x7fc6bf6c287e - trans::expr::unsized_info::h0bc39e6848f6110aiYB
17: 0x7fc6bf711951 - trans::expr::coerce_unsized::h8e89613ca17d7dbfV8B
18: 0x7fc6bf630370 - trans::expr::trans::h03a0bd43be9e4742XQB
19: 0x7fc6bf6d9d28 - trans::expr::trans_into::h662ed888b6e8c1b0HKB
20: 0x7fc6bf753396 - trans::_match::mk_binding_alloca::h10679163847645854849
21: 0x7fc6bf63cd97 - trans::base::init_local::h02dc2b39e6ae81bbV4h
22: 0x7fc6bf6596e6 - trans::controlflow::trans_block::h585e8da605e23045Mnw
23: 0x7fc6bf658866 - trans::base::trans_closure::he2605a1779eef7004Si
24: 0x7fc6bf659fd4 - trans::base::trans_fn::h74b850e8a7063830R2i
25: 0x7fc6bf65d268 - trans::base::trans_item::h0626e4f7c3d136c3Tsj
26: 0x7fc6bf66a0ad - trans::base::trans_crate::h484196896109b43fMek
27: 0x7fc6c047c7fd - driver::phase_4_translate_to_llvm::he6fb5be0cc962bd8CNa
28: 0x7fc6c0476d1f - driver::phase_3_run_analysis_passes::closure.20607
29: 0x7fc6c0450e25 - middle::ty::ctxt<'tcx>::create_and_enter::h8359765683570227848
30: 0x7fc6c044bf8d - driver::phase_3_run_analysis_passes::h11291711653950599435
31: 0x7fc6c042f6a6 - driver::compile_input::heca4840d0344a3e0Tba
32: 0x7fc6c059a43b - run_compiler::h649c0dbc32ddf7b3Obc
33: 0x7fc6c0597d07 - boxed::F.FnBox<A>::call_box::h2938814597307836325
34: 0x7fc6c0597774 - rt::unwind::try::try_fn::h12878677813726277739
35: 0x7fc6bff2e848 - __rust_try
36: 0x7fc6bff1b1a2 - rt::unwind::try::inner_try::h3201fe634cf03d94EAw
37: 0x7fc6c0597908 - boxed::F.FnBox<A>::call_box::h3379161078959787353
38: 0x7fc6bff2dc93 - sys::thread::Thread::new::thread_start::h124abd3234105a89rKv
39: 0x7fc6b9b1c181 - start_thread
40: 0x7fc6bfba947c - __clone
41: 0x0 - <unknown>
The expected behavior is for the entities_filtered function to not exist or not be callable when ComponentMapper::Component does not implement filterable. ICE on Stable, Beta, and Nightly.