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 normalizing binder for closure #103771

Closed
jruderman opened this issue Oct 30, 2022 · 2 comments · Fixed by #103780
Closed

ICE normalizing binder for closure #103771

jruderman opened this issue Oct 30, 2022 · 2 comments · Fixed by #103780
Assignees
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. F-closure_lifetime_binder `#![feature(closure_lifetime_binder)]` 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

@jruderman
Copy link
Contributor

Code

#![feature(closure_lifetime_binder)]
fn main() {
    for<'a> || -> () {
        for<'c> |_: &'a ()| -> () {
        }
    };
}

Error output

thread 'rustc' panicked at 'Normalizing Binder(([&'a ()]; c_variadic: false)->(), [Region(BrNamed(DefId(0:7 ~ amina[00f1]::main::{closure#0}::{closure#0}::'c), 'c))]) without wrapping in a `Binder`', /rustc/0da281b6068a7d889ae89a9bd8991284cc9b7535/compiler/rustc_trait_selection/src/traits/project.rs:450:9
Full output including backtrace

thread 'rustc' panicked at 'Normalizing Binder(([&'a ()]; c_variadic: false)->(), [Region(BrNamed(DefId(0:7 ~ amina[00f1]::main::{closure#0}::{closure#0}::'c), 'c))]) without wrapping in a `Binder`', /rustc/0da281b6068a7d889ae89a9bd8991284cc9b7535/compiler/rustc_trait_selection/src/traits/project.rs:450:9
stack backtrace:
   0:        0x108f348a2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h98e7719cdb057d8f
   1:        0x108f8c74a - core::fmt::write::he324e6f3a7ef7ed0
   2:        0x108f2697c - std::io::Write::write_fmt::h295c914c323e508a
   3:        0x108f3466a - std::sys_common::backtrace::print::hb2f2bd76d0a1d9b2
   4:        0x108f37a76 - std::panicking::default_hook::{{closure}}::h7f2a23a911934152
   5:        0x108f377c7 - std::panicking::default_hook::h576cf5867894044c
   6:        0x11755262d - rustc_driver[ba5c792b9438c2b]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x108f38271 - std::panicking::rust_panic_with_hook::hf0781b554a936fbf
   8:        0x108f38003 - std::panicking::begin_panic_handler::{{closure}}::h8d2525e276d552d8
   9:        0x108f34d38 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3badbbd5492e2d6
  10:        0x108f37ccd - _rust_begin_unwind
  11:        0x108fb91b3 - core::panicking::panic_fmt::h15d4409e62dc090a
  12:        0x119e69dab - <rustc_trait_selection[9c2b695c7caa8425]::traits::project::AssocTypeNormalizer>::fold::<rustc_middle[298407787cc28eff]::ty::sty::Binder<rustc_middle[298407787cc28eff]::ty::sty::FnSig>>
  13:        0x119e80346 - rustc_trait_selection[9c2b695c7caa8425]::traits::project::normalize::<rustc_middle[298407787cc28eff]::ty::sty::Binder<rustc_middle[298407787cc28eff]::ty::sty::FnSig>>
  14:        0x119ee32b6 - <rustc_infer[b40902abbc4e8850]::infer::InferCtxt as rustc_trait_selection[9c2b695c7caa8425]::infer::InferCtxtExt>::partially_normalize_associated_types_in::<rustc_middle[298407787cc28eff]::ty::sty::Binder<rustc_middle[298407787cc28eff]::ty::sty::FnSig>>
  15:        0x119e8e808 - <rustc_hir_typeck[82128e1af9fabaca]::inherited::Inherited>::normalize_associated_types_in::<rustc_middle[298407787cc28eff]::ty::sty::Binder<rustc_middle[298407787cc28eff]::ty::sty::FnSig>>
  16:        0x119daed4b - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::supplied_sig_of_closure
  17:        0x119dac8cb - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_closure
  18:        0x119dafe14 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_kind
  19:        0x119d59556 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:        0x119d6f655 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_block_with_expected
  21:        0x119db07a8 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_kind
  22:        0x119d59556 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:        0x119d5a59a - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_return_expr
  24:        0x119ecbd6e - rustc_hir_typeck[82128e1af9fabaca]::check::check_fn
  25:        0x119dacdda - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_closure
  26:        0x119dafe14 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_kind
  27:        0x119d59556 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:        0x119d6eeb5 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_stmt
  29:        0x119d6f5ff - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_block_with_expected
  30:        0x119db07a8 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_kind
  31:        0x119d59556 - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  32:        0x119d5a59a - <rustc_hir_typeck[82128e1af9fabaca]::fn_ctxt::FnCtxt>::check_return_expr
  33:        0x119ecbd6e - rustc_hir_typeck[82128e1af9fabaca]::check::check_fn
  34:        0x119e9265c - rustc_hir_typeck[82128e1af9fabaca]::typeck
  35:        0x11ad3bfb9 - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<rustc_span[73e074df7cba0abf]::def_id::LocalDefId, &rustc_middle[298407787cc28eff]::ty::context::TypeckResults>>
  36:        0x11ae3d04c - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::typeck, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  37:        0x119ebbb6b - rustc_data_structures[445d045225b5bae3]::sync::par_for_each_in::<&[rustc_span[73e074df7cba0abf]::def_id::LocalDefId], <rustc_middle[298407787cc28eff]::hir::map::Map>::par_body_owners<rustc_hir_typeck[82128e1af9fabaca]::typeck_item_bodies::{closure#0}>::{closure#0}>
  38:        0x119e8fb8d - rustc_hir_typeck[82128e1af9fabaca]::typeck_item_bodies
  39:        0x11add14a9 - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<(), ()>>
  40:        0x11ae31a39 - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::typeck_item_bodies, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  41:        0x119fb4ed4 - <rustc_session[43d2d941ace548e5]::session::Session>::time::<(), rustc_hir_analysis[3f5a3f8b91adb05]::check_crate::{closure#7}>
  42:        0x119f6546f - rustc_hir_analysis[3f5a3f8b91adb05]::check_crate
  43:        0x11762afda - rustc_interface[a666f6d755ed9279]::passes::analysis
  44:        0x11adc326c - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<(), core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>>
  45:        0x11ae3d3f9 - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::analysis, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  46:        0x1174e1296 - <rustc_interface[a666f6d755ed9279]::passes::QueryContext>::enter::<rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  47:        0x117525a4d - rustc_span[73e074df7cba0abf]::with_source_map::<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  48:        0x11751534c - <scoped_tls[c17fceff1b2b43d8]::ScopedKey<rustc_span[73e074df7cba0abf]::SessionGlobals>>::set::<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  49:        0x1174e4e5a - std[8878bd7dd366d71b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a666f6d755ed9279]::util::run_in_thread_pool_with_globals<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  50:        0x1174caf7b - <<std[8878bd7dd366d71b]::thread::Builder>::spawn_unchecked_<rustc_interface[a666f6d755ed9279]::util::run_in_thread_pool_with_globals<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#1} as core[13371b8ce97f01bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:        0x108f41387 - std::sys::unix::thread::Thread::new::thread_start::hfd54df40dd14130e
  52:     0x7ff814d514e1 - __pthread_start

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.66.0-nightly (0da281b60 2022-10-27) running on x86_64-apple-darwin

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

Version

rustc 1.66.0-nightly (0da281b60 2022-10-27)
binary: rustc
commit-hash: 0da281b6068a7d889ae89a9bd8991284cc9b7535
commit-date: 2022-10-27
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2

Bisect results

This goes all the way back to f1a8854, when #98705 enabled this syntax for closures (tracking issue: #97362).

@jruderman jruderman 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 Oct 30, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Oct 30, 2022

This is very likely the same root cause as #103736, where we should be treating an outer late lifetime as a free region within the closure's body.

@compiler-errors
Copy link
Member

I've got half of a solution anyways, just fixing a subsequent ICE that arises after fixing this one.

@compiler-errors compiler-errors self-assigned this Oct 30, 2022
@estebank estebank added the A-closures Area: Closures (`|…| { … }`) label Oct 31, 2022
@bors bors closed this as completed in d10187f Nov 4, 2022
@WaffleLapkin WaffleLapkin added the F-closure_lifetime_binder `#![feature(closure_lifetime_binder)]` label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. F-closure_lifetime_binder `#![feature(closure_lifetime_binder)]` 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.

4 participants