Closed
Description
I'm using a lifetime parameter on a trait such that I can constrain Item
to for <'a> &'a X
. I tried to "encapsulate" the lifetime into a subtrait to avoid other issues and got an ICE on stable, nightly and with/without NLL. I suspect this usage should error but I could be mistaken.
trait Sink {
type Item;
fn next(&mut self, Self::Item);
}
trait SinkA<'a>: Sink {}
struct X(u8);
fn abc<I>(mut i: I) where for<'a> I: SinkA<'a, Item=&'a X> {
let x = X(0);
i.next(&x);
}
error: internal compiler error: librustc/infer/higher_ranked/mod.rs:160: no representative region for `ReSkolemized(UniverseIndex(1), BrNamed(crate0:DefIndex(1:13), 'a))` in `{ReSkolemized(UniverseIndex(1), BrNamed(crate0:DefIndex(1:13), 'a))}`
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:515
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::session::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: rustc::ty::context::tls::with_context_opt
11: rustc::ty::context::tls::with_opt
12: rustc::session::opt_span_bug_fmt
13: rustc::session::bug_fmt
14: rustc::infer::higher_ranked::<impl rustc::infer::combine::CombineFields<'a, 'gcx, 'tcx>>::higher_ranked_match::{{closure}}::{{closure}}::{{closure}}
15: <std::collections::hash::map::HashMap<K, V, S> as core::iter::traits::FromIterator<(K, V)>>::from_iter
16: rustc::infer::InferCtxt::commit_if_ok
17: rustc::infer::InferCtxt::match_poly_projection_predicate
18: rustc::traits::project::confirm_param_env_candidate
19: rustc::traits::project::opt_normalize_projection_type
20: rustc::traits::project::normalize_projection_type
21: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
22: <rustc_data_structures::accumulate_vec::AccumulateVec<A> as core::iter::traits::FromIterator<<A as rustc_data_structures::array_vec::Array>::Element>>::from_iter
23: rustc::ty::fold::TypeFoldable::fold_with
24: rustc::ty::fold::TypeFoldable::fold_with
25: rustc::traits::project::normalize
26: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once
27: <core::iter::FlatMap<I, U, F> as core::iter::iterator::Iterator>::next
28: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
29: rustc::ty::wf::WfPredicates::normalize
30: rustc::ty::wf::predicate_obligations
31: rustc_typeck::check::wfcheck::check_where_clauses
32: rustc_typeck::check::wfcheck::check_fn_or_method
33: rustc::ty::context::tls::with_related_context
34: rustc::infer::InferCtxtBuilder::enter
35: rustc_typeck::check::wfcheck::check_item_well_formed
36: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::check_item_well_formed<'tcx>>::compute
37: rustc::dep_graph::graph::DepGraph::with_task_impl
38: rustc::ty::context::tls::with_related_context
39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
42: rustc::hir::Crate::visit_all_item_likes
43: rustc::session::Session::track_errors
44: rustc::util::common::time
45: rustc_typeck::check_crate
46: rustc::ty::context::tls::enter_context
47: <std::thread::local::LocalKey<T>>::with
48: rustc::ty::context::TyCtxt::create_and_enter
49: rustc_driver::driver::compile_input
50: rustc_driver::run_compiler_with_pool
51: <scoped_tls::ScopedKey<T>>::set
52: syntax::with_globals
53: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
54: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
55: rustc_driver::run
56: rustc_driver::main
57: std::rt::lang_start::{{closure}}
58: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
59: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
60: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
61: main
62: __libc_start_main
63: <unknown>
query stack during panic:
#0 [check_item_well_formed] processing `abc`
end of query stackerror: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: rustc 1.28.0 (9634041f0 2018-07-30) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib