Skip to content

ICE(async_await,futures_api,await_macro,generators): cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(2)) <= '_#1r #57084

Description

@stbuehler

I tried to write a generic async wrapper for something similar to tokio_reactor::PollEvented that calls poll_..., clear_... and yield depending on the io::Result of an operation and got the error mentioned in the subject.

I managed to reduce the code triggering it to this:

#![feature(async_await,futures_api,await_macro,generators)]

pub struct Foo;

impl Foo {
	async fn with<'a, F, R>(&'a self, f: F) -> R
	where
		F: Fn() -> R + 'a,
	{
		loop {
			match f() {
				_ => yield,
			}
		}
	}

	pub async fn run<'a>(&'a self, data: &'a [u8])
	{
		await!(self.with(move || {
			println!("{:p}", data);
		}))
	}
}

fn main() {
}

(Playground)

Probably related to #53989.

Full error message:

error: internal compiler error: src/librustc/infer/region_constraints/mod.rs:683: cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(2)) <= '_#1r

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:538:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:72
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:60
             at src/libstd/panicking.rs:210
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:225
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:492
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::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::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: rustc::infer::region_constraints::RegionConstraintCollector::make_subregion
  15: rustc::infer::region_constraints::RegionConstraintCollector::make_eqregion
  16: <rustc::infer::equate::Equate<'combine, 'infcx, 'gcx, 'tcx> as rustc::ty::relate::TypeRelation<'infcx, 'gcx, 'tcx>>::regions
  17: rustc::ty::relate::super_relate_tys
  18: rustc::infer::combine::<impl rustc::infer::InferCtxt<'infcx, 'gcx, 'tcx>>::super_combine_tys
  19: <rustc::infer::equate::Equate<'combine, 'infcx, 'gcx, 'tcx> as rustc::ty::relate::TypeRelation<'infcx, 'gcx, 'tcx>>::tys
  20: <rustc::ty::subst::Kind<'tcx> as rustc::ty::relate::Relate<'tcx>>::relate
  21: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  22: <I as rustc::ty::context::InternAs<[T], R>>::intern_with
  23: <rustc::ty::sty::TraitRef<'tcx> as rustc::ty::relate::Relate<'tcx>>::relate
  24: rustc::infer::InferCtxt::commit_if_ok
  25: rustc::traits::select::SelectionContext::match_impl
  26: rustc::infer::InferCtxt::probe
  27: rustc::ty::trait_def::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::for_each_relevant_impl
  28: rustc::traits::select::SelectionContext::assemble_candidates_from_impls
  29: rustc::traits::select::SelectionContext::assemble_candidates
  30: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  31: rustc::ty::context::tls::with_context
  32: rustc::dep_graph::graph::DepGraph::with_anon_task
  33: rustc::traits::select::SelectionContext::candidate_from_obligation
  34: rustc::traits::select::SelectionContext::evaluate_stack
  35: rustc::ty::context::tls::with_context
  36: rustc::dep_graph::graph::DepGraph::with_anon_task
  37: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  38: rustc::infer::InferCtxt::probe
  39: rustc::traits::select::SelectionContext::evaluate_stack
  40: rustc::ty::context::tls::with_context
  41: rustc::dep_graph::graph::DepGraph::with_anon_task
  42: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  43: rustc::infer::InferCtxt::probe
  44: rustc::traits::select::SelectionContext::evaluate_stack
  45: rustc::ty::context::tls::with_context
  46: rustc::dep_graph::graph::DepGraph::with_anon_task
  47: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  48: rustc::infer::InferCtxt::probe
  49: rustc::traits::select::SelectionContext::evaluate_stack
  50: rustc::ty::context::tls::with_context
  51: rustc::dep_graph::graph::DepGraph::with_anon_task
  52: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  53: rustc::infer::InferCtxt::probe
  54: rustc::traits::select::SelectionContext::evaluate_stack
  55: rustc::ty::context::tls::with_context
  56: rustc::dep_graph::graph::DepGraph::with_anon_task
  57: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  58: rustc::infer::InferCtxt::probe
  59: rustc::traits::select::SelectionContext::evaluate_stack
  60: rustc::ty::context::tls::with_context
  61: rustc::dep_graph::graph::DepGraph::with_anon_task
  62: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  63: rustc::infer::InferCtxt::probe
  64: rustc::traits::select::SelectionContext::evaluate_stack
  65: rustc::ty::context::tls::with_context
  66: rustc::dep_graph::graph::DepGraph::with_anon_task
  67: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  68: rustc::infer::InferCtxt::probe
  69: rustc::traits::select::SelectionContext::evaluate_stack
  70: rustc::ty::context::tls::with_context
  71: rustc::dep_graph::graph::DepGraph::with_anon_task
  72: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  73: rustc::infer::InferCtxt::probe
  74: rustc::traits::select::SelectionContext::evaluate_stack
  75: rustc::ty::context::tls::with_context
  76: rustc::dep_graph::graph::DepGraph::with_anon_task
  77: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  78: rustc::traits::select::SelectionContext::evaluate_obligation_recursively
  79: rustc::ty::context::tls::with_related_context
  80: rustc_traits::evaluate_obligation::evaluate_obligation
  81: rustc::ty::query::__query_compute::evaluate_obligation
  82: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::evaluate_obligation<'tcx>>::compute
  83: rustc::ty::context::tls::with_context
  84: rustc::dep_graph::graph::DepGraph::with_task_impl
  85: rustc::ty::context::tls::with_related_context
  86: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  87: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  88: rustc::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation
  89: rustc::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation_no_overflow
  90: rustc::traits::type_known_to_meet_bound
  91: rustc::ty::context::tls::with_related_context
  92: rustc::infer::InferCtxtBuilder::enter
  93: rustc::ty::util::is_freeze_raw
  94: rustc::ty::query::__query_compute::is_freeze_raw
  95: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::is_freeze_raw<'tcx>>::compute
  96: rustc::ty::context::tls::with_context
  97: rustc::dep_graph::graph::DepGraph::with_task_impl
  98: rustc::ty::context::tls::with_related_context
  99: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `[static generator@src/main.rs:18:2: 22:3 self:&Foo, data:&[u8] for<'r, 's, 't0> {impl std::future::Future, ()}]: std::marker::Freeze`
#1 [is_freeze_raw] computing whether `[static generator@src/main.rs:18:2: 22:3 self:&'a Foo, data:&'a [u8] for<'r, 's, 't0> {impl std::future::Future, ()}]` is freeze
#2 [mir_validated] processing `Foo::run::{{closure}}`
#3 [mir_borrowck] processing `Foo::run::{{closure}}`
end of query stack
error: aborting due to previous error


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.33.0-nightly (2d3e909e4 2018-12-22) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions