Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread 'rustc' panicked at 'assertion failed: !erased_self_ty.has_escaping_bound_vars()' #86800

Closed
fourbytes opened this issue Jul 2, 2021 · 4 comments · Fixed by #94081 or #113648
Closed
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fourbytes
Copy link

fourbytes commented Jul 2, 2021

Code

#![feature(min_type_alias_impl_trait)]
use std::future::Future;

struct Connection {
}

trait Transaction {
}

struct TestTransaction<'conn> {
    conn: &'conn Connection
}

impl<'conn> Transaction for TestTransaction<'conn> {
}

struct Context {
}

type TransactionResult<O> = Result<O, ()>;

type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;

fn execute_transaction_fut<'f, F, O>(f: F) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<O>
where
    F: FnOnce(&mut dyn Transaction) -> TransactionFuture<O> + 'f
{
    f
}

impl Context {
    async fn do_transaction<O>(
        &self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<O>
    ) -> TransactionResult<O>
    {
        let mut conn = Connection {};
        let mut transaction = TestTransaction { conn: &mut conn };
        f(&mut transaction).await
    }
}

Meta

rustc --version --verbose:

rustc 1.55.0-nightly (a435b49e8 2021-06-28)
binary: rustc
commit-hash: a435b49e86d16e98dcc6595dd471f95e823f41aa
commit-date: 2021-06-28
host: x86_64-apple-darwin
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

thread 'rustc' panicked at 'assertion failed: !erased_self_ty.has_escaping_bound_vars()', compiler/rustc_trait_selection/src/opaque_types.rs:1182:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (a435b49e8 2021-06-28) running on x86_64-apple-darwin

note: compiler flags: -C opt-level=3 -C embed-bitcode=no --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `ice1::execute_transaction_fut`
#1 [type_of] computing type of `ice1::TransactionFuture::{opaque#0}`
end of query stack
error: could not compile `rust-playground`
Backtrace

   Compiling rust-playground v0.1.0 (/Users/fourbytes/Projects/rust-playground)
thread 'rustc' panicked at 'assertion failed: !erased_self_ty.has_escaping_bound_vars()', compiler/rustc_trait_selection/src/opaque_types.rs:1182:5
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_trait_selection::opaque_types::Instantiator::fold_opaque_ty
   4: <rustc_middle::ty::fold::BottomUpFolder<F,G,H> as rustc_middle::ty::fold::TypeFolder>::fold_ty
   5: rustc_middle::ty::fold::TypeFoldable::fold_with
   6: rustc_trait_selection::opaque_types::Instantiator::fold_opaque_ty
   7: <rustc_middle::ty::fold::BottomUpFolder<F,G,H> as rustc_middle::ty::fold::TypeFolder>::fold_ty
   8: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::instantiate_opaque_types_from_value
   9: rustc_typeck::check::check::check_fn
  10: rustc_infer::infer::InferCtxtBuilder::enter
  11: rustc_typeck::check::typeck
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::force_query_with_job
  15: rustc_query_system::query::plumbing::get_query_impl
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  17: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
  18: rustc_hir::intravisit::walk_item
  19: rustc_typeck::collect::type_of::type_of
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  21: rustc_data_structures::stack::ensure_sufficient_stack
  22: rustc_query_system::query::plumbing::force_query_with_job
  23: rustc_query_system::query::plumbing::get_query_impl
  24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  25: rustc_typeck::check::check::check_item_type
  26: rustc_middle::hir::map::Map::visit_item_likes_in_module
  27: rustc_typeck::check::check::check_mod_item_types
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::force_query_with_job
  31: rustc_query_system::query::plumbing::get_query_impl
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  33: rustc_session::utils::<impl rustc_session::session::Session>::time
  34: rustc_typeck::check_crate
  35: rustc_interface::passes::analysis
  36: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  37: rustc_data_structures::stack::ensure_sufficient_stack
  38: rustc_query_system::query::plumbing::force_query_with_job
  39: rustc_query_system::query::plumbing::get_query_impl
  40: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  41: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  42: rustc_span::with_source_map
  43: rustc_interface::interface::create_compiler_and_run
  44: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (a435b49e8 2021-06-28) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `ice1::execute_transaction_fut`
#1 [type_of] computing type of `ice1::TransactionFuture::{opaque#0}`
#2 [check_mod_item_types] checking item types in module `ice1`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `rust-playground`

To learn more, run the command again with --verbose.

@fourbytes fourbytes added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 2, 2021
@FabianWolff
Copy link
Contributor

Might be related to #83693.

@compiler-errors
Copy link
Member

Re-opening due to #99860

@langston-barrett
Copy link

langston-barrett commented Mar 13, 2023

Here's a more minimal version:

type TransactionFuture<'__, O> = impl '__;
fn execute_transaction_fut<'f, F, O>() -> FnOnce(&Transaction) -> TransactionFuture<'_, O> {
    f
}

This gives a slightly different error message, probably just due to updates in rustc since when this was first filed.

error: internal compiler error: compiler/rustc_hir_typeck/src/inherited.rs:130:13: escaping bound vars in predicate Obligation(predicate=Binder(TraitPredicate(<TransactionFuture<'_, O> as std::marker::Sized>, polarity:Positive), []), depth=0)
 --> ice_min.rs:2:43
  |
2 | fn execute_transaction_fut<'f, F, O>() -> FnOnce(&Transaction) -> TransactionFuture<'_, O> {
  |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rustc 1.70.0-nightly (ff4b772f8 2023-03-10)
binary: rustc
commit-hash: ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13
commit-date: 2023-03-10
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Minimized with treereduce.

@JohnTitor
Copy link
Member

Triage: Fixed on the latest nightly, @rustbot labels: +E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 24, 2023
@bors bors closed this as completed in e595409 Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
9 participants