Skip to content

ICE with async function: 'leak-check would have us replace ReStatic with BrAnon(1)' #55499

Closed

Description

@pcpthm

I tried this code Playground. I tried to make this code as minimal as possible.

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

trait MyClosure {
    type Args;
}
impl<R> MyClosure for dyn FnMut() -> R
where R: 'static {
    type Args = ();
}
struct MyStream<C: ?Sized + MyClosure> {
    x: C::Args,
}
// or get_future() -> futures::future::Ready<()> { futures::future::ready(()) }
async fn get_future<C: ?Sized + MyClosure>(_stream: MyStream<C>) {
}
async fn f() {
    let messages: MyStream<FnMut()> = unimplemented!();
    await!(get_future(messages));
}

Result:

thread 'main' panicked at 'leak-check would have us replace ReStatic with BrAnon(1)', librustc/infer/higher_ranked/mod.rs:763: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:480
   6: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   7: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:345
   8: rustc::infer::higher_ranked::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::plug_leaks::{{closure}}
   9: <rustc::ty::fold::RegionFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_binder
  10: rustc::ty::fold::TypeFoldable::fold_with
  11: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::fold
  12: rustc::ty::fold::TypeFoldable::fold_with
  13: rustc::infer::higher_ranked::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::plug_leaks
  14: rustc::infer::InferCtxt::in_snapshot
  15: <core::iter::FlatMap<I, U, F> as core::iter::iterator::Iterator>::next
  16: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  17: rustc::traits::select::SelectionContext::collect_predicates_for_types
  18: rustc::traits::select::SelectionContext::confirm_candidate
  19: rustc::infer::InferCtxt::probe
  20: rustc::traits::select::SelectionContext::evaluate_stack
  21: rustc::dep_graph::graph::DepGraph::with_anon_task
  22: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  23: rustc::infer::InferCtxt::probe
  24: rustc::traits::select::SelectionContext::evaluate_stack
  25: rustc::dep_graph::graph::DepGraph::with_anon_task
  26: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  27: rustc::infer::InferCtxt::probe
  28: rustc::traits::select::SelectionContext::evaluate_stack
  29: rustc::dep_graph::graph::DepGraph::with_anon_task
  30: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  31: rustc::traits::select::SelectionContext::evaluate_obligation_recursively
  32: rustc::ty::context::tls::with_related_context
  33: rustc::infer::InferCtxtBuilder::enter_with_canonical
  34: rustc_traits::evaluate_obligation::evaluate_obligation
  35: rustc::ty::query::__query_compute::evaluate_obligation
  36: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::evaluate_obligation<'tcx>>::compute
  37: rustc::dep_graph::graph::DepGraph::with_task_impl
  38: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  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::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation
  42: rustc::traits::query::evaluate_obligation::<impl rustc::infer::InferCtxt<'cx, 'gcx, 'tcx>>::evaluate_obligation_no_overflow
  43: rustc::traits::type_known_to_meet_bound
  44: rustc::ty::context::tls::with_related_context
  45: rustc::infer::InferCtxtBuilder::enter
  46: rustc::ty::util::is_freeze_raw
  47: rustc::ty::query::__query_compute::is_freeze_raw
  48: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::is_freeze_raw<'tcx>>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  53: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::is_freeze
  54: rustc_mir::transform::qualify_consts::Qualifier::new
  55: <rustc_mir::transform::qualify_consts::QualifyAndPromoteConstants as rustc_mir::transform::MirPass>::run_pass
  56: rustc_mir::transform::mir_validated::{{closure}}
  57: rustc_mir::transform::mir_validated
  58: rustc::ty::query::__query_compute::mir_validated
  59: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_validated<'tcx>>::compute
  60: rustc::dep_graph::graph::DepGraph::with_task_impl
  61: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  62: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  63: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  64: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_validated
  65: rustc_mir::borrow_check::mir_borrowck
  66: rustc::ty::query::__query_compute::mir_borrowck
  67: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_borrowck<'tcx>>::compute
  68: rustc::dep_graph::graph::DepGraph::with_task_impl
  69: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  70: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  71: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  72: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_borrowck
  73: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
  74: rustc::util::common::time
  75: rustc::ty::context::tls::enter_context
  76: <std::thread::local::LocalKey<T>>::with
  77: rustc::ty::context::TyCtxt::create_and_enter
  78: rustc_driver::driver::compile_input
  79: rustc_driver::run_compiler_with_pool
  80: rustc_driver::driver::spawn_thread_pool
  81: rustc_driver::run_compiler
  82: <scoped_tls::ScopedKey<T>>::set
  83: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  84: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  85: rustc_driver::run
  86: rustc_driver::main
  87: std::rt::lang_start::{{closure}}
  88: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  89: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  90: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  91: main
  92: __libc_start_main
  93: <unknown>
query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `[static generator@src/lib.rs:16:14: 19:2 for<'r, 's> {MyStream<(dyn std::ops::FnMut() + 'r)>, impl std::future::Future, ()}]: std::marker::Freeze`
#1 [is_freeze_raw] computing whether `[static generator@src/lib.rs:16:14: 19:2 for<'r, 's> {MyStream<(dyn std::ops::FnMut() + 'r)>, impl std::future::Future, ()}]` is freeze
#2 [mir_validated] processing `f::{{closure}}`
#3 [mir_borrowck] processing `f::{{closure}}`
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.31.0-nightly (4bd4e4130 2018-10-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Oct 30, 2018
  2. pnkfelix commented on Mar 29, 2019

    @pnkfelix
    Contributor

    This ICE no longer occurs on the nightly compiler.

    Marking as E-needs-test so that we don't forget to add a regression test for it.

  3. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Mar 29, 2019
  4. added 2 commits that reference this issue on Apr 28, 2019
    561f9fc
    3091961
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-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