Closed
Description
Returning a Higher Ranked Trait Bound closure ICE's on stable (1.28), beta and nightly:
fn bug() -> impl for <'r> Fn() -> &'r () { || { &() } }
fn main() {
let f = bug();
}
Backtrace:
error: internal compiler error: librustc/infer/higher_ranked/mod.rs:160: no representative region for `ReSkolemized(UniverseIndex(2), BrAnon(1))` in `{ReSkolemized(UniverseIndex(2), BrAnon(1))}`
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::confirm_callable_candidate
20: rustc::traits::project::opt_normalize_projection_type
21: rustc::traits::project::project_and_unify_type
22: rustc::infer::InferCtxt::commit_if_ok
23: <rustc::traits::fulfill::FulfillmentContext<'tcx> as rustc::traits::engine::TraitEngine<'tcx>>::select_where_possible
24: rustc_typeck::check::FnCtxt::select_obligations_where_possible
25: rustc::ty::context::tls::with_related_context
26: rustc::infer::InferCtxtBuilder::enter
27: rustc_typeck::check::typeck_tables_of
28: rustc::ty::query::__query_compute::typeck_tables_of
29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
30: rustc::dep_graph::graph::DepGraph::with_task_impl
31: rustc::ty::context::tls::with_related_context
32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
34: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
35: rustc_typeck::collect::type_of
36: rustc::ty::query::__query_compute::type_of
37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::type_of<'tcx>>::compute
38: rustc::dep_graph::graph::DepGraph::with_task_impl
39: rustc::ty::context::tls::with_related_context
40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
42: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::type_of
43: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
44: rustc::hir::Crate::visit_all_item_likes
45: rustc::session::Session::track_errors
46: rustc_typeck::check_crate
47: rustc::ty::context::tls::enter_context
48: <std::thread::local::LocalKey<T>>::with
49: rustc::ty::context::TyCtxt::create_and_enter
50: rustc_driver::driver::compile_input
51: rustc_driver::run_compiler_with_pool
52: <scoped_tls::ScopedKey<T>>::set
53: syntax::with_globals
54: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
55: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
56: rustc_driver::run
57: rustc_driver::main
58: std::rt::lang_start::{{closure}}
59: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
60: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
61: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:392
at libstd/rt.rs:58
62: main
63: __libc_start_main
64: <unknown>
query stack during panic:
#0 [typeck_tables_of] processing `bug`
#1 [type_of] processing `bug::{{exist-impl-Trait}}`
end of query stack
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0582`.
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.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 bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `playground`.
To learn more, run the command again with --verbose.