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

ICE: assertion failed: !value.has_escaping_bound_vars(), compiler/rustc_middle/src/ty/sty.rs:971:9 #95023

Closed
matthiaskrgr opened this issue Mar 16, 2022 · 3 comments · Fixed by #95085
Assignees
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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 16, 2022

Code

struct ErrorKind;
struct Error(ErrorKind);
impl Fn(&isize) for Error {
    fn foo<const N: usize>(&self) -> Self::B<{N}>;
}
fn main() {}

Meta

This crashes rustcs as old as 1.56.1 so probably different from #94998 (didn't try any older rustcs though.)

rustc --version --verbose:

binary: rustc
commit-hash: 52b34550aca5f7dd7e152f773e3ab786acb86f6f
commit-date: 2022-03-15
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

error: associated function in `impl` without body
 --> icemaker_62324.rs:4:5
  |
4 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
  |                                                  |
  |                                                  help: provide a definition for the function: `{ <body> }`

error[E0407]: method `foo` is not a member of trait `Fn`
 --> icemaker_62324.rs:4:5
  |
4 |     fn foo<const N: usize>(&self) -> Self::B<{N}>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Fn`

error[E0183]: manual implementations of `Fn` are experimental
 --> icemaker_62324.rs:3:6
  |
3 | impl Fn(&isize) for Error {
  |      ^^^^^^^^^^ manual implementations of `Fn` are experimental
  |
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable

error[E0229]: associated type bindings are not allowed here
 --> icemaker_62324.rs:3:6
  |
3 | impl Fn(&isize) for Error {
  |      ^^^^^^^^^^ associated type not allowed here

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/compiler/rustc_middle/src/ty/sty.rs:1089:9
Backtrace

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/compiler/rustc_middle/src/ty/sty.rs:1089:9
stack backtrace:
   0:     0x7f32d589d9bd - std::backtrace_rs::backtrace::libunwind::trace::h4630fb3ea0978244
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f32d589d9bd - std::backtrace_rs::backtrace::trace_unsynchronized::hf18a5a72046346f1
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f32d589d9bd - std::sys_common::backtrace::_print_fmt::hf749d0aa30a58698
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f32d589d9bd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9b8410cdaf24e94d
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f32d58f749c - core::fmt::write::h4628ef2f511cb2a1
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f32d588ef41 - std::io::Write::write_fmt::h0500ef668fc0f1ca
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/io/mod.rs:1655:15
   6:     0x7f32d58a0a35 - std::sys_common::backtrace::_print::h0bef26ee54194799
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f32d58a0a35 - std::sys_common::backtrace::print::hd94733c6e7c5f533
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f32d58a0a35 - std::panicking::default_hook::{{closure}}::heee50b6b48941df3
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/panicking.rs:295:22
   9:     0x7f32d58a06e9 - std::panicking::default_hook::hfbe8348e52a92768
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/panicking.rs:314:9
  10:     0x7f32d60ca291 - rustc_driver[689e96f3a05e42de]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f32d58a1180 - std::panicking::rust_panic_with_hook::h123c71abd7d4640f
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/panicking.rs:702:17
  12:     0x7f32d58a0f79 - std::panicking::begin_panic_handler::{{closure}}::h4dff286ac3d07322
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/panicking.rs:586:13
  13:     0x7f32d589de74 - std::sys_common::backtrace::__rust_end_short_backtrace::h1350a023dcdb3181
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f32d58a0ce9 - rust_begin_unwind
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/panicking.rs:584:5
  15:     0x7f32d5864c73 - core::panicking::panic_fmt::hdc1c83fe453b97e2
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/core/src/panicking.rs:143:14
  16:     0x7f32d5864b3d - core::panicking::panic::hb1922f21f0c33350
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/core/src/panicking.rs:48:5
  17:     0x7f32d82048e6 - <dyn rustc_typeck[e0aa7dd1248ba06]::astconv::AstConv>::associated_path_to_ty
  18:     0x7f32d753c814 - <dyn rustc_typeck[e0aa7dd1248ba06]::astconv::AstConv>::ast_ty_to_ty_inner
  19:     0x7f32d7533bca - <dyn rustc_typeck[e0aa7dd1248ba06]::astconv::AstConv>::ty_of_fn
  20:     0x7f32d74ce22c - rustc_typeck[e0aa7dd1248ba06]::collect::fn_sig
  21:     0x7f32d799aafa - rustc_query_system[ccda753483a689aa]::query::plumbing::try_execute_query::<rustc_query_impl[7c11a1a95cade8b5]::plumbing::QueryCtxt, rustc_query_system[ccda753483a689aa]::query::caches::DefaultCache<rustc_span[71d6b32be7db1b29]::def_id::DefId, rustc_middle[f9f9a681d39429ab]::ty::sty::Binder<rustc_middle[f9f9a681d39429ab]::ty::sty::FnSig>>>
  22:     0x7f32d7a7234f - <rustc_query_impl[7c11a1a95cade8b5]::Queries as rustc_middle[f9f9a681d39429ab]::ty::query::QueryEngine>::fn_sig
  23:     0x7f32d74cbbd4 - <rustc_typeck[e0aa7dd1248ba06]::collect::CollectItemTypesVisitor as rustc_hir[109eb1f3004517cd]::intravisit::Visitor>::visit_impl_item
  24:     0x7f32d753e2eb - <rustc_middle[f9f9a681d39429ab]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir[109eb1f3004517cd]::intravisit::DeepVisitor<rustc_typeck[e0aa7dd1248ba06]::collect::CollectItemTypesVisitor>>
  25:     0x7f32d81c75c9 - rustc_typeck[e0aa7dd1248ba06]::collect::collect_mod_item_types
  26:     0x7f32d7992aae - rustc_query_system[ccda753483a689aa]::query::plumbing::try_execute_query::<rustc_query_impl[7c11a1a95cade8b5]::plumbing::QueryCtxt, rustc_query_system[ccda753483a689aa]::query::caches::DefaultCache<rustc_span[71d6b32be7db1b29]::def_id::LocalDefId, ()>>
  27:     0x7f32d844c753 - rustc_query_system[ccda753483a689aa]::query::plumbing::get_query::<rustc_query_impl[7c11a1a95cade8b5]::queries::collect_mod_item_types, rustc_query_impl[7c11a1a95cade8b5]::plumbing::QueryCtxt>
  28:     0x7f32d820f683 - <rustc_middle[f9f9a681d39429ab]::hir::map::Map>::for_each_module::<rustc_typeck[e0aa7dd1248ba06]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  29:     0x7f32d81d99c5 - <rustc_session[b6943ffe4755727e]::session::Session>::track_errors::<rustc_typeck[e0aa7dd1248ba06]::check_crate::{closure#0}, ()>
  30:     0x7f32d81d702d - rustc_typeck[e0aa7dd1248ba06]::check_crate
  31:     0x7f32d7f5db87 - rustc_interface[ed5ba2b564642d99]::passes::analysis
  32:     0x7f32d8416bfe - rustc_query_system[ccda753483a689aa]::query::plumbing::try_execute_query::<rustc_query_impl[7c11a1a95cade8b5]::plumbing::QueryCtxt, rustc_query_system[ccda753483a689aa]::query::caches::DefaultCache<(), core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>>
  33:     0x7f32d845629e - rustc_query_system[ccda753483a689aa]::query::plumbing::get_query::<rustc_query_impl[7c11a1a95cade8b5]::queries::analysis, rustc_query_impl[7c11a1a95cade8b5]::plumbing::QueryCtxt>
  34:     0x7f32d7f3b617 - <rustc_interface[ed5ba2b564642d99]::passes::QueryContext>::enter::<rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>
  35:     0x7f32d7f18d38 - <rustc_interface[ed5ba2b564642d99]::interface::Compiler>::enter::<rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}::{closure#2}, core[2748ca54e7081f8b]::result::Result<core[2748ca54e7081f8b]::option::Option<rustc_interface[ed5ba2b564642d99]::queries::Linker>, rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>
  36:     0x7f32d7f2bddf - rustc_span[71d6b32be7db1b29]::with_source_map::<core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>, rustc_interface[ed5ba2b564642d99]::interface::create_compiler_and_run<core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>, rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}>::{closure#1}>
  37:     0x7f32d7f2b5e4 - rustc_interface[ed5ba2b564642d99]::interface::create_compiler_and_run::<core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>, rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}>
  38:     0x7f32d7f16762 - <scoped_tls[a18bab56a8f82071]::ScopedKey<rustc_span[71d6b32be7db1b29]::SessionGlobals>>::set::<rustc_interface[ed5ba2b564642d99]::interface::run_compiler<core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>, rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}>::{closure#0}, core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>
  39:     0x7f32d7f14c1f - std[14bdc88f27c1cbe3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ed5ba2b564642d99]::util::run_in_thread_pool_with_globals<rustc_interface[ed5ba2b564642d99]::interface::run_compiler<core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>, rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}>::{closure#0}, core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>::{closure#0}, core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>
  40:     0x7f32d7f2cd62 - <<std[14bdc88f27c1cbe3]::thread::Builder>::spawn_unchecked_<rustc_interface[ed5ba2b564642d99]::util::run_in_thread_pool_with_globals<rustc_interface[ed5ba2b564642d99]::interface::run_compiler<core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>, rustc_driver[689e96f3a05e42de]::run_compiler::{closure#1}>::{closure#0}, core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>::{closure#0}, core[2748ca54e7081f8b]::result::Result<(), rustc_errors[31a36e023e39c2ba]::ErrorGuaranteed>>::{closure#1} as core[2748ca54e7081f8b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f32d58ab313 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd90ad1cbe107fac7
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/alloc/src/boxed.rs:1853:9
  42:     0x7f32d58ab313 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h47f9929b43ba9f68
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/alloc/src/boxed.rs:1853:9
  43:     0x7f32d58ab313 - std::sys::unix::thread::Thread::new::thread_start::hf5007aed9e46726b
                               at /rustc/52b34550aca5f7dd7e152f773e3ab786acb86f6f/library/std/src/sys/unix/thread.rs:108:17
  44:     0x7f32d56835c2 - start_thread
  45:     0x7f32d5708584 - __clone
  46:                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.61.0-nightly (52b34550a 2022-03-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `<impl at icemaker_62324.rs:3:1: 5:2>::foo`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0183, E0229, E0407.
For more information about an error, try `rustc --explain E0183`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 16, 2022
@compiler-errors
Copy link
Member

This is probably a bug in the way that we lower impl Fn(&_) that lets a late-bound region escape. I can probably take a look at this later, though guessing it's low-pri since it requires a feature and triggers errors before the ICE occurs.

@lqd
Copy link
Member

lqd commented Mar 16, 2022

I think it's a variant of #85350 btw, it now ICEs like this.

@ouz-a
Copy link
Contributor

ouz-a commented Mar 18, 2022

@rustbot claim

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

Successfully merging a pull request may close this issue.

5 participants