Skip to content

'assertion failed: current_depth > ty::DebruijnIndex::INNERMOST' when using generators #51353

@ngg

Description

@ngg

I've got an ICE when I tried to use async/await support from futures-0.2 together with impl traits. I've tried to minimized the code, now there are no external dependencies:

// ice.rs

#![feature(generators)]

trait Future {
    type Item;
}

struct Join<T: Future>(T::Item);

impl<F: Fn() -> ()> Future for F
{
    type Item = ();
}

fn join<T: Future<Item = ()>>(_: T) -> Join<T>
{
    Join(())
}

fn ice<'a>() -> impl Send + 'a {
    join(|| ())
}

fn main() {
    || {
        let _f = ice();
        yield;
    };
}

Running RUST_BACKTRACE=1 rustc ice.rs on the latest rustc 1.28.0-nightly (29f48ccf3 2018-06-03) gives the following output:

thread 'main' panicked at 'assertion failed: current_depth > ty::DebruijnIndex::INNERMOST', librustc/infer/higher_ranked/mod.rs:738:21
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::infer::higher_ranked::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::plug_leaks::{{closure}}
   8: <rustc_data_structures::array_vec::ArrayVec<A> as core::iter::traits::Extend<<A as rustc_data_structures::array_vec::Array>::Element>>::extend
   9: rustc::ty::fold::TypeFoldable::fold_with
  10: rustc::ty::fold::TypeFoldable::fold_with
  11: rustc::ty::fold::TypeFoldable::fold_with
  12: rustc::infer::InferCtxt::commit_if_ok
  13: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  14: rustc::infer::InferCtxt::probe
  15: rustc::traits::select::SelectionContext::evaluate_stack
  16: rustc::dep_graph::graph::DepGraph::with_anon_task
  17: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  18: rustc::infer::InferCtxt::probe
  19: rustc::traits::select::SelectionContext::evaluate_stack
  20: rustc::dep_graph::graph::DepGraph::with_anon_task
  21: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  22: rustc::infer::InferCtxt::probe
  23: rustc::traits::select::SelectionContext::evaluate_stack
  24: rustc::dep_graph::graph::DepGraph::with_anon_task
  25: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  26: rustc::infer::InferCtxt::probe
  27: rustc::traits::select::SelectionContext::evaluate_stack
  28: rustc::dep_graph::graph::DepGraph::with_anon_task
  29: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  30: rustc::traits::select::SelectionContext::evaluate_obligation_recursively
  31: rustc::ty::context::tls::with_related_context
  32: rustc::infer::InferCtxtBuilder::enter
  33: rustc_traits::evaluate_obligation::evaluate_obligation
  34: rustc::ty::maps::__query_compute::evaluate_obligation
  35: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::evaluate_obligation<'tcx>>::compute
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
  37: rustc::ty::context::tls::with_related_context
  38: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  39: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  40: rustc::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation
  41: rustc::traits::type_known_to_meet_bound
  42: rustc::ty::context::tls::with_related_context
  43: rustc::infer::InferCtxtBuilder::enter
  44: rustc::ty::util::is_freeze_raw
  45: rustc::ty::maps::__query_compute::is_freeze_raw
  46: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::is_freeze_raw<'tcx>>::compute
  47: rustc::dep_graph::graph::DepGraph::with_task_impl
  48: rustc::ty::context::tls::with_related_context
  49: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  50: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  51: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::is_freeze
  52: rustc_mir::transform::qualify_consts::Qualifier::new
  53: <rustc_mir::transform::qualify_consts::QualifyAndPromoteConstants as rustc_mir::transform::MirPass>::run_pass
  54: rustc_mir::transform::mir_validated::{{closure}}
  55: rustc_mir::transform::mir_validated
  56: rustc::ty::maps::__query_compute::mir_validated
  57: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::mir_validated<'tcx>>::compute
  58: rustc::dep_graph::graph::DepGraph::with_task_impl
  59: rustc::ty::context::tls::with_related_context
  60: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  61: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  62: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  63: rustc_borrowck::borrowck::borrowck
  64: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::borrowck<'tcx>>::compute
  65: rustc::dep_graph::graph::DepGraph::with_task_impl
  66: rustc::ty::context::tls::with_related_context
  67: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  68: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  69: <rustc_borrowck::borrowck::unused::UsedMutFinder<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
  70: rustc::hir::intravisit::walk_expr
  71: rustc_borrowck::borrowck::unused::check
  72: rustc_borrowck::borrowck::borrowck
  73: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::borrowck<'tcx>>::compute
  74: rustc::dep_graph::graph::DepGraph::with_task_impl
  75: rustc::ty::context::tls::with_related_context
  76: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  77: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  78: rustc_borrowck::borrowck::check_crate
  79: rustc::util::common::time
  80: rustc::ty::context::tls::enter_context
  81: <std::thread::local::LocalKey<T>>::with
  82: rustc::ty::context::TyCtxt::create_and_enter
  83: rustc_driver::driver::compile_input
  84: rustc_driver::run_compiler_with_pool
  85: <scoped_tls::ScopedKey<T>>::set
  86: syntax::with_globals
  87: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  88: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  89: rustc_driver::run
  90: rustc_driver::main
  91: std::rt::lang_start::{{closure}}
  92: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  93: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  94: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  95: main
  96: __libc_start_main
  97: <unknown>
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `[generator@ice.rs:24:5: 27:6 for<'r, 's> {impl std::marker::Send, ()}]: std::marker::Freeze`
#1 [is_freeze_raw] computing whether `[generator@ice.rs:24:5: 27:6 for<'r, 's> {impl std::marker::Send, ()}]` is freeze
#2 [mir_validated] processing `main::{{closure}}`
#3 [borrowck] processing `main::{{closure}}`
#4 [borrowck] processing `main`
end of query stack

error: internal compiler error: unexpected panic

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-nightly (29f48ccf3 2018-06-03) running on x86_64-unknown-linux-gnu

[1]    14102 exit 101   RUST_BACKTRACE=1 rustc ice.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-coroutinesArea: CoroutinesC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions