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

assertion failed: !value.has_escaping_bound_vars() #89189

Closed
vorot93 opened this issue Sep 22, 2021 · 2 comments
Closed

assertion failed: !value.has_escaping_bound_vars() #89189

vorot93 opened this issue Sep 22, 2021 · 2 comments
Labels
C-bug Category: This is a bug. 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

@vorot93
Copy link

vorot93 commented Sep 22, 2021

Code

This commit reliably crashes rustc:
akula-bft/akula@b28cbce

I haven't managed to minify this as the following works just fine:

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

pub trait Encode {
    type Encoded;

    fn encode(self) -> Self::Encoded;
}

impl Encode for u64 {
    type Encoded = [u8; 8];

    fn encode(self) -> Self::Encoded {
        self.to_be_bytes()
    }
}

impl<A, B, const A_LEN: usize, const B_LEN: usize> Encode for (A, B)
where
    A: Encode<Encoded = [u8; A_LEN]>,
    B: Encode<Encoded = [u8; B_LEN]>,
    [u8; A_LEN + B_LEN]: AsRef<[u8]>,
{
    type Encoded = [u8; A_LEN + B_LEN];

    fn encode(self) -> Self::Encoded {
        let mut v = [0; A_LEN + B_LEN];
        v[..A_LEN].copy_from_slice(&self.0.encode());
        v[A_LEN..].copy_from_slice(&self.1.encode());
        v
    }
}

fn main() {
    assert_eq!(Encode::encode((0, 0)), [0; 16]);
}

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (ac2d9fc50 2021-09-21)
binary: rustc
commit-hash: ac2d9fc509e36d1b32513744adf58c34bcc4f43c
commit-date: 2021-09-21
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output and backtrace

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/compiler/rustc_middle/src/ty/sty.rs:971:9
stack backtrace:
   0:     0x7fb310ef651c - std::backtrace_rs::backtrace::libunwind::trace::h2ab374bc2a3b7023
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fb310ef651c - std::backtrace_rs::backtrace::trace_unsynchronized::h128cb5178b04dc46
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb310ef651c - std::sys_common::backtrace::_print_fmt::h5344f9eefca2041f
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fb310ef651c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h213003bc5c7acf04
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fb310f547dc - core::fmt::write::h78bf85fc3e93663f
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/core/src/fmt/mod.rs:1126:17
   5:     0x7fb310ee7405 - std::io::Write::write_fmt::he619515c888f21a5
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/io/mod.rs:1667:15
   6:     0x7fb310ef9a80 - std::sys_common::backtrace::_print::hf706674f77848203
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fb310ef9a80 - std::sys_common::backtrace::print::hf0b6c7a88804ec56
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fb310ef9a80 - std::panicking::default_hook::{{closure}}::h2dde766cd83a333a
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/panicking.rs:210:50
   9:     0x7fb310ef9637 - std::panicking::default_hook::h501e3b2e134eb149
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/panicking.rs:227:9
  10:     0x7fb3116dbe11 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h8ff5de92123cb8fd
  11:     0x7fb2fee289f3 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcaa339890b8e6472
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/alloc/src/boxed.rs:1650:9
  12:     0x7fb2fee2bd8d - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::hbacbce1e3e000948
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7fb310efa299 - std::panicking::rust_panic_with_hook::hc09e869c4cf00885
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/panicking.rs:628:17
  14:     0x7fb310ef9d22 - std::panicking::begin_panic_handler::{{closure}}::hc2c6d70142458fc8
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/panicking.rs:519:13
  15:     0x7fb310ef69c4 - std::sys_common::backtrace::__rust_end_short_backtrace::had58f7c459a1cd6e
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/sys_common/backtrace.rs:141:18
  16:     0x7fb310ef9cb9 - rust_begin_unwind
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/panicking.rs:517:5
  17:     0x7fb310ebf861 - core::panicking::panic_fmt::hf443e5eeb6cc9eab
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/core/src/panicking.rs:103:14
  18:     0x7fb310ebf7ad - core::panicking::panic::h50b51d19800453c0
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/core/src/panicking.rs:50:5
  19:     0x7fb3130feeba - rustc_trait_selection::traits::wf::WfPredicates::compute::h451c719e098064fd
  20:     0x7fb3130fc9a6 - rustc_trait_selection::traits::wf::obligations::h5b5581296da2e62f
  21:     0x7fb3130ac919 - rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations::ha0aa535d762060d9
  22:     0x7fb3130c444b - rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations::h9b19112ccc099349
  23:     0x7fb3130abe4c - rustc_trait_selection::traits::fulfill::FulfillmentContext::select::h5feaa97543394f08
  24:     0x7fb3130ac5b2 - <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_with_constness_where_possible::h3885ead61348d1bd
  25:     0x7fb3130ac320 - <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_all_with_constness_or_error::h09a89888f1392f5a
  26:     0x7fb3129f2ec1 - rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::select_all_obligations_or_error::hcea71775409d9908
  27:     0x7fb312a66676 - rustc_infer::infer::InferCtxtBuilder::enter::hb9b185b080f31781
  28:     0x7fb312a2ae03 - rustc_typeck::check::typeck::hd320344c890821b5
  29:     0x7fb313899ef1 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h387037e7d39cafef
  30:     0x7fb313841f43 - rustc_data_structures::stack::ensure_sufficient_stack::h9e9042d5d4151ec7
  31:     0x7fb312de3b65 - rustc_query_system::query::plumbing::try_execute_query::h5bbb54711c9a400d
  32:     0x7fb312e5ce49 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck::h32b5ef98ec541fe2
  33:     0x7fb31319016c - rustc_middle::ty::context::TyCtxt::typeck_opt_const_arg::hd8495a4ee78e8a50
  34:     0x7fb312c2dca5 - rustc_mir_build::build::mir_built::hf1d3206186982bda
  35:     0x7fb31388d1cb - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h04fbae3ecd8247ff
  36:     0x7fb313848bd5 - rustc_data_structures::stack::ensure_sufficient_stack::hfd752616032c7244
  37:     0x7fb312df508c - rustc_query_system::query::plumbing::try_execute_query::hbfac2572e6fdd956
  38:     0x7fb312e5b131 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_built::hb0174b933d0dcf4a
  39:     0x7fb3129ac573 - rustc_mir_transform::check_unsafety::unsafety_check_result::h2855d05d664d09ed
  40:     0x7fb3129a89ca - core::ops::function::FnOnce::call_once::h3ce14a99508d3a8a
  41:     0x7fb3138c3c01 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::hec0938501a20b61f
  42:     0x7fb31383f013 - rustc_data_structures::stack::ensure_sufficient_stack::h744d6d334b641c8b
  43:     0x7fb312df3395 - rustc_query_system::query::plumbing::try_execute_query::hab979f6c36b68b4b
  44:     0x7fb312e5ca4f - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result::h267ac8e757c55ecb
  45:     0x7fb3129a2854 - rustc_mir_transform::mir_const::hc5a3b65ee147fc8e
  46:     0x7fb31388d1cb - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h04fbae3ecd8247ff
  47:     0x7fb313848bd5 - rustc_data_structures::stack::ensure_sufficient_stack::hfd752616032c7244
  48:     0x7fb312df508c - rustc_query_system::query::plumbing::try_execute_query::hbfac2572e6fdd956
  49:     0x7fb312e5b281 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const::h74f2e1d3e042aff3
  50:     0x7fb3129a3bbe - rustc_mir_transform::mir_promoted::ha2e008bd04ccb8a5
  51:     0x7fb31388eca1 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h0a4b22006de86808
  52:     0x7fb313847047 - rustc_data_structures::stack::ensure_sufficient_stack::he760321fc26d1c7c
  53:     0x7fb312e12307 - rustc_query_system::query::plumbing::get_query::h5683cd12099c7a66
  54:     0x7fb312cfb9c6 - rustc_borrowck::mir_borrowck::h43f04ab543d2f43f
  55:     0x7fb312cf6d61 - core::ops::function::FnOnce::call_once::h8103cea540657a78
  56:     0x7fb313894621 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h289a71605f390793
  57:     0x7fb31383c403 - rustc_data_structures::stack::ensure_sufficient_stack::h4b6e02134b2da06d
  58:     0x7fb312df411d - rustc_query_system::query::plumbing::try_execute_query::hb362ed745d75a2d5
  59:     0x7fb312e5d0a9 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck::hf27d489416d05e03
  60:     0x7fb312a9a8fc - rustc_typeck::collect::type_of::type_of::hca9404ffc74f128f
  61:     0x7fb3138bcf28 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::hc3aeb153f8ce060b
  62:     0x7fb31383d346 - rustc_data_structures::stack::ensure_sufficient_stack::h592a81c1112cc4b9
  63:     0x7fb312de2015 - rustc_query_system::query::plumbing::try_execute_query::h4d6ef156dd398725
  64:     0x7fb312e5a8f6 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of::h407cb8e429259267
  65:     0x7fb3130dde58 - rustc_trait_selection::traits::select::confirmation::<impl rustc_trait_selection::traits::select::SelectionContext>::confirm_candidate::h7b30d6040a1a88cd
  66:     0x7fb3130e0405 - rustc_trait_selection::traits::select::SelectionContext::select::h44ccb99a80e00d65
  67:     0x7fb3130adbbe - rustc_trait_selection::traits::fulfill::FulfillProcessor::process_trait_obligation::h656af21652ddab63
  68:     0x7fb3130ac8c6 - rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations::ha0aa535d762060d9
  69:     0x7fb3130c444b - rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations::h9b19112ccc099349
  70:     0x7fb3130abe4c - rustc_trait_selection::traits::fulfill::FulfillmentContext::select::h5feaa97543394f08
  71:     0x7fb3130ac5b2 - <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_with_constness_where_possible::h3885ead61348d1bd
  72:     0x7fb3130ac320 - <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_all_with_constness_or_error::h09a89888f1392f5a
  73:     0x7fb3129f2ec1 - rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::select_all_obligations_or_error::hcea71775409d9908
  74:     0x7fb312a66676 - rustc_infer::infer::InferCtxtBuilder::enter::hb9b185b080f31781
  75:     0x7fb312a2ae03 - rustc_typeck::check::typeck::hd320344c890821b5
  76:     0x7fb313899ef1 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h387037e7d39cafef
  77:     0x7fb313841f43 - rustc_data_structures::stack::ensure_sufficient_stack::h9e9042d5d4151ec7
  78:     0x7fb312de3b65 - rustc_query_system::query::plumbing::try_execute_query::h5bbb54711c9a400d
  79:     0x7fb312e5ce49 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck::h32b5ef98ec541fe2
  80:     0x7fb311a5c0b4 - rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check::hccbb4f8b5324fe71
  81:     0x7fb311a5bc6b - <rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_impl_item::hcbae69c379d200c3
  82:     0x7fb311a5a6b5 - rustc_hir::intravisit::Visitor::visit_nested_impl_item::h72982611d2d7762b
  83:     0x7fb3119df782 - rustc_hir::intravisit::walk_item::h5b06274924ecd69a
  84:     0x7fb312a9c268 - rustc_typeck::collect::type_of::type_of::hca9404ffc74f128f
  85:     0x7fb3138bcf28 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::hc3aeb153f8ce060b
  86:     0x7fb31383d346 - rustc_data_structures::stack::ensure_sufficient_stack::h592a81c1112cc4b9
  87:     0x7fb312de2015 - rustc_query_system::query::plumbing::try_execute_query::h4d6ef156dd398725
  88:     0x7fb312e5a8f6 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of::h407cb8e429259267
  89:     0x7fb312aa84c5 - rustc_typeck::check::check::check_item_type::hb275e936432d1428
  90:     0x7fb312a8b035 - rustc_middle::hir::map::Map::visit_item_likes_in_module::h2d01a6d23ae7f6ed
  91:     0x7fb31359113c - rustc_typeck::check::check::check_mod_item_types::h940e5223b070e957
  92:     0x7fb3138b8a31 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::hb80f32bec4db4096
  93:     0x7fb313848a03 - rustc_data_structures::stack::ensure_sufficient_stack::hfa8581b71108d87a
  94:     0x7fb312ddd6f9 - rustc_query_system::query::plumbing::try_execute_query::h3f20ac888ca305a2
  95:     0x7fb3138582e5 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types::he4d05ba02aacdd3d
  96:     0x7fb313581798 - rustc_middle::hir::map::Map::for_each_module::hb81c3a6c8e183c36
  97:     0x7fb3135cade0 - rustc_typeck::check_crate::h7feb9290e351ef2e
  98:     0x7fb313291870 - rustc_interface::passes::analysis::hb918b02982537851
  99:     0x7fb313898a6f - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h347feb22cb0d1ecf
 100:     0x7fb31383c539 - rustc_data_structures::stack::ensure_sufficient_stack::h4b6ffa4a2dfebaef
 101:     0x7fb313780dbb - rustc_query_system::query::plumbing::try_execute_query::h784269645558384c
 102:     0x7fb3138568d2 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis::ha8ab0b7748e9a5d1
 103:     0x7fb313288749 - rustc_interface::passes::QueryContext::enter::h805836b6c10e023c
 104:     0x7fb31326f724 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hded9061889acb733
 105:     0x7fb31325ca45 - rustc_span::with_source_map::hce3a664e96079636
 106:     0x7fb31326f04c - scoped_tls::ScopedKey<T>::set::h033dd5b45ac9d9cd
 107:     0x7fb31325da7d - std::sys_common::backtrace::__rust_begin_short_backtrace::hc72d766e7b5b424b
 108:     0x7fb31325b2e5 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hdbb85447b47f9f9d
 109:     0x7fb310f06e33 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h59eef3b9c8a82350
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/alloc/src/boxed.rs:1636:9
 110:     0x7fb310f06e33 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb5bbe017c347469c
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/alloc/src/boxed.rs:1636:9
 111:     0x7fb310f06e33 - std::sys::unix::thread::Thread::new::thread_start::h62931528f61e35f5
                               at /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c/library/std/src/sys/unix/thread.rs:106:17
 112:     0x7fb310e1c259 - start_thread
 113:     0x7fb310d315e3 - __GI___clone
 114:                0x0 - <unknown>

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.57.0-nightly (ac2d9fc50 2021-09-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [typeck] type-checking `changeset::storage::do_search_2`
#1 [mir_built] building MIR for `changeset::storage::do_search_2`
#2 [unsafety_check_result] unsafety-checking `changeset::storage::do_search_2`
#3 [mir_const] processing MIR for `changeset::storage::do_search_2`
#4 [mir_promoted] processing `changeset::storage::do_search_2`
#5 [mir_borrowck] borrow-checking `changeset::storage::do_search_2`
#6 [type_of] computing type of `changeset::storage::do_search_2::{opaque#0}`
#7 [typeck] type-checking `changeset::storage::<impl at src/changeset/storage.rs:7:1: 76:2>::find`
#8 [type_of] computing type of `changeset::storage::<impl at src/changeset/storage.rs:7:1: 76:2>::EncodedStream::{opaque#0}`
#9 [check_mod_item_types] checking item types in module `changeset::storage`
#10 [analysis] running analysis passes on this crate
end of query stack

@vorot93 vorot93 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 Sep 22, 2021
@RobinMarchart
Copy link

I might have found another more minimal example that panics at the same place.
although this piece of code is syntactically wrong, it probably should not crash the compiler

#![feature(fn_traits,unboxed_closures)]
struct Func{}
impl Fn(&str)->bool for Func{
    extern "rust-call" fn call(&self, args: Args) -> Self::Output {
        todo!()
    }
}

playground link

@Alexendoo
Copy link
Member

Fixed by #95085

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. 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
Development

No branches or pull requests

4 participants