Closed
Description
I found a Internal Compiler Error on stable, beta and nighly and was able to reproduce it in the playground. If the function do_something
is not async, everything works fine. If it is, the minimal verifiable example below will fail:
Code (Playground)
trait TraitA<'a> {
type ReturnA: TraitB;
}
trait TraitB {
type ReturnB;
}
trait TraitC {}
struct ImplementorA {}
impl<'a> TraitA<'a> for ImplementorA {
type ReturnA = ImplementorB<'a>;
}
struct ImplementorB<'a>(std::marker::PhantomData<&'a ()>);
impl<'a> TraitB for ImplementorB<'a> {
type ReturnB = ();
}
impl TraitC for () {}
struct Container<T>(std::marker::PhantomData<T>);
impl<T> Container<T> where T: 'static, for<'a> T: TraitA<'a> {
async fn do_something() -> impl TraitC where for<'a> <<T as TraitA<'a>>::ReturnA as TraitB>::ReturnB: 'static {
()
}
}
Meta
rustc --version --verbose
:
rustc 1.53.0 (53cb7b09b 2021-06-17) running on x86_64-unknown-linux-gnu
Error output
error: internal compiler error: compiler/rustc_mir/src/borrow_check/universal_regions.rs:782:36: cannot convert `RePlaceholder(Placeholder { universe: U2, name: BrNamed(DefId(0:29 ~ playground[828e]::{impl#3}::do_something::'a), 'a) })` to a region vid
thread 'rustc' panicked at 'Box<Any>', /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panic.rs:59:5
Backtrace
Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_mir/src/borrow_check/universal_regions.rs:782:36: cannot convert `RePlaceholder(Placeholder { universe: U2, name: BrNamed(DefId(0:29 ~ playground[828e]::{impl#3}::do_something::'a), 'a) })` to a region vid
thread 'rustc' panicked at 'Box<Any>', /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panic.rs:59:5
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::bug
3: rustc_errors::Handler::bug
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_mir::borrow_check::universal_regions::UniversalRegionIndices::to_region_vid
8: rustc_mir::borrow_check::region_infer::RegionInferenceContext::eval_verify_bound
9: rustc_mir::borrow_check::region_infer::RegionInferenceContext::solve
10: rustc_mir::borrow_check::nll::compute_regions
11: rustc_mir::borrow_check::do_mir_borrowck
12: rustc_infer::infer::InferCtxtBuilder::enter
13: rustc_mir::borrow_check::mir_borrowck
14: core::ops::function::FnOnce::call_once
15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
16: rustc_data_structures::stack::ensure_sufficient_stack
17: rustc_query_system::query::plumbing::force_query_with_job
18: rustc_query_system::query::plumbing::get_query_impl
19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
20: rustc_typeck::collect::type_of::type_of
21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
22: rustc_data_structures::stack::ensure_sufficient_stack
23: rustc_query_system::query::plumbing::force_query_with_job
24: rustc_query_system::query::plumbing::get_query_impl
25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
26: rustc_typeck::check::check::check_opaque
27: rustc_typeck::check::check::check_item_type
28: rustc_middle::hir::map::Map::visit_item_likes_in_module
29: rustc_typeck::check::check::check_mod_item_types
30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
31: rustc_query_system::query::plumbing::force_query_with_job
32: rustc_query_system::query::plumbing::get_query_impl
33: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
34: rustc_session::utils::<impl rustc_session::session::Session>::time
35: rustc_typeck::check_crate
36: rustc_interface::passes::analysis
37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
38: rustc_data_structures::stack::ensure_sufficient_stack
39: rustc_query_system::query::plumbing::force_query_with_job
40: rustc_query_system::query::plumbing::get_query_impl
41: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
42: rustc_interface::passes::QueryContext::enter
43: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
44: rustc_span::with_source_map
45: rustc_interface::interface::create_compiler_and_run
46: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.53.0 (53cb7b09b 2021-06-17) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at src/lib.rs:25:1: 29:2>::do_something`
#1 [type_of] computing type of `<impl at src/lib.rs:25:1: 29:2>::do_something::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
error: could not compile `playground`
To learn more, run the command again with --verbose.