Skip to content

[ICE]: debuginfo: has escaping bound vars, so it cannot be wrapped in a dummy binder. #159576

Description

@matthiaskrgr

Code

this crashes as soon as we turn on -Cdebuginfo=2 🤔

// @compile-flags: --crate-type lib -Cdebuginfo=2
#![feature(unsafe_binders)]
pub fn woof() -> unsafe<'a, 'b> &'b Box<dyn Fn(Box<dyn Fn() -> &'a isize>)> {
    todo!()
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (eff8269f7 2026-07-18)
binary: rustc
commit-hash: eff8269f797067c30555e77f160ec84c0ed15cd9
commit-date: 2026-07-18
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Error output

warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> code.rs:1:12
  |
1 | #![feature(unsafe_binders)]
  |            ^^^^^^^^^^^^^^
  |
  = note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: function `main` is never used
 --> code.rs:5:4
  |
5 | fn main() {}
  |    ^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
Backtrace

thread 'rustc' (2324859) panicked at /rustc-dev/eff8269f797067c30555e77f160ec84c0ed15cd9/compiler/rustc_middle/src/ty/predicate.rs:492:9:
`<dyn std::ops::Fn(std::boxed::Box<dyn std::ops::Fn() -> &'a isize>) as std::marker::Sized>` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
   0:     0x7febb2450a16 - <<std[2a8c3cd46992084f]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f0447a45d83adb47]::fmt::Display>::fmt
   1:     0x7febb2a0ec88 - core[f0447a45d83adb47]::fmt::write
   2:     0x7febb2465c7c - <std[2a8c3cd46992084f]::sys::stdio::unix::Stderr as core[f0447a45d83adb47]::io::write::Write>::write_fmt
   3:     0x7febb24226aa - std[2a8c3cd46992084f]::panicking::default_hook::{closure#0}
   4:     0x7febb2443143 - std[2a8c3cd46992084f]::panicking::default_hook
   5:     0x7febb13fc04b - std[2a8c3cd46992084f]::panicking::update_hook::<alloc[4a894a599ddd1b2d]::boxed::Box<rustc_driver_impl[c2a64f8504684822]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7febb24435e2 - std[2a8c3cd46992084f]::panicking::panic_with_hook
   7:     0x7febb2422762 - std[2a8c3cd46992084f]::panicking::panic_handler::{closure#0}
   8:     0x7febb2419509 - std[2a8c3cd46992084f]::sys::backtrace::__rust_end_short_backtrace::<std[2a8c3cd46992084f]::panicking::panic_handler::{closure#0}, !>
   9:     0x7febb24240bd - __rustc[4368d8ad29db066c]::rust_begin_unwind
  10:     0x7febaf1de9fc - core[f0447a45d83adb47]::panicking::panic_fmt
  11:     0x7febb3de88d5 - rustc_trait_selection[230890ec563485ea]::traits::type_known_to_meet_bound_modulo_regions
  12:     0x7febb30fba34 - rustc_ty_utils[49543d609ee060eb]::common_traits::is_trait_raw
  13:     0x7febb30fb61b - rustc_query_impl[5a309cdb9f26d392]::query_impl::is_sized_raw::invoke_provider_fn::__rust_begin_short_backtrace
  14:     0x7febb2e7e4f3 - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 1usize]>>, false>
  15:     0x7febb2e7def4 - rustc_query_impl[5a309cdb9f26d392]::query_impl::is_sized_raw::execute_query_non_incr::__rust_end_short_backtrace
  16:     0x7febb368a230 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of_uncached
  17:     0x7febb3684ab8 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of
  18:     0x7febb36849d1 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7febb340bdad - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 16usize]>>, false>
  20:     0x7febb2a00298 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7febb355c6d8 - <rustc_middle[96c442875f2cb62c]::ty::layout::LayoutCx as rustc_middle[96c442875f2cb62c]::ty::layout::LayoutOf>::spanned_layout_of
  22:     0x7febb3687176 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of_uncached
  23:     0x7febb3684ab8 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of
  24:     0x7febb36849d1 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7febb340bdad - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 16usize]>>, false>
  26:     0x7febb2a00298 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7febb368607e - rustc_ty_utils[49543d609ee060eb]::layout::layout_of_uncached
  28:     0x7febb3684ab8 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of
  29:     0x7febb36849d1 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
  30:     0x7febb340bdad - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 16usize]>>, false>
  31:     0x7febb2a00298 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7febb368607e - rustc_ty_utils[49543d609ee060eb]::layout::layout_of_uncached
  33:     0x7febb3684ab8 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of
  34:     0x7febb36849d1 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7febb340bdad - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 16usize]>>, false>
  36:     0x7febb2a00298 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7febb368607e - rustc_ty_utils[49543d609ee060eb]::layout::layout_of_uncached
  38:     0x7febb3684ab8 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of
  39:     0x7febb36849d1 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
  40:     0x7febb340bdad - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 16usize]>>, false>
  41:     0x7febb2a00298 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7febb3684cc7 - rustc_ty_utils[49543d609ee060eb]::layout::layout_of
  43:     0x7febb36849d1 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
  44:     0x7febb340bdad - rustc_query_impl[5a309cdb9f26d392]::execution::try_execute_query::<rustc_middle[96c442875f2cb62c]::query::caches::DefaultCache<rustc_middle[96c442875f2cb62c]::ty::PseudoCanonicalInput<rustc_middle[96c442875f2cb62c]::ty::Ty>, rustc_middle[96c442875f2cb62c]::query::erase::ErasedData<[u8; 16usize]>>, false>
  45:     0x7febb2a00298 - rustc_query_impl[5a309cdb9f26d392]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
  46:     0x7febb32889af - rustc_codegen_llvm[f79ed61bf9e9a770]::debuginfo::metadata::build_pointer_or_reference_di_node
  47:     0x7febb3282394 - rustc_codegen_llvm[f79ed61bf9e9a770]::debuginfo::metadata::spanned_type_di_node
  48:     0x7febb3287b04 - rustc_codegen_llvm[f79ed61bf9e9a770]::debuginfo::metadata::build_pointer_or_reference_di_node
  49:     0x7febb3282394 - rustc_codegen_llvm[f79ed61bf9e9a770]::debuginfo::metadata::spanned_type_di_node
  50:     0x7febb124d011 - rustc_codegen_llvm[f79ed61bf9e9a770]::debuginfo::metadata::build_unsafe_binder_type_di_node
  51:     0x7febb3283fc2 - rustc_codegen_llvm[f79ed61bf9e9a770]::debuginfo::metadata::spanned_type_di_node
  52:     0x7febafd5e51a - <rustc_codegen_llvm[f79ed61bf9e9a770]::builder::GenericBuilder<rustc_codegen_llvm[f79ed61bf9e9a770]::context::FullCx> as rustc_codegen_ssa[a1a5dff3a5e40db9]::traits::debuginfo::DebugInfoBuilderMethods>::dbg_scope_fn
  53:     0x7febb3d8d50a - rustc_codegen_ssa[a1a5dff3a5e40db9]::mir::codegen_mir::<rustc_codegen_llvm[f79ed61bf9e9a770]::builder::GenericBuilder<rustc_codegen_llvm[f79ed61bf9e9a770]::context::FullCx>>
  54:     0x7febb2b11ff6 - rustc_codegen_llvm[f79ed61bf9e9a770]::base::compile_codegen_unit::module_codegen
  55:     0x7febb3cadd7f - <rustc_codegen_llvm[f79ed61bf9e9a770]::LlvmCodegenBackend as rustc_codegen_ssa[a1a5dff3a5e40db9]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  56:     0x7febb3caa1ea - rustc_codegen_ssa[a1a5dff3a5e40db9]::base::codegen_crate::<rustc_codegen_llvm[f79ed61bf9e9a770]::LlvmCodegenBackend, rustc_codegen_llvm[f79ed61bf9e9a770]::ModuleLlvm>
  57:     0x7febb3ca840d - <rustc_codegen_llvm[f79ed61bf9e9a770]::LlvmCodegenBackend as rustc_codegen_ssa[a1a5dff3a5e40db9]::traits::backend::CodegenBackend>::codegen_crate
  58:     0x7febb3a19ca4 - <rustc_interface[bb04609e4c960450]::queries::Linker>::codegen_and_build_linker
  59:     0x7febb3b0470e - rustc_interface[bb04609e4c960450]::interface::run_compiler::<(), rustc_driver_impl[c2a64f8504684822]::run_compiler::{closure#0}>::{closure#2}
  60:     0x7febb3b72ae4 - std[2a8c3cd46992084f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[bb04609e4c960450]::util::run_in_thread_with_globals<rustc_interface[bb04609e4c960450]::util::run_in_thread_pool_with_globals<rustc_interface[bb04609e4c960450]::interface::run_compiler<(), rustc_driver_impl[c2a64f8504684822]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  61:     0x7febb3b728bb - <std[2a8c3cd46992084f]::thread::lifecycle::spawn_unchecked<rustc_interface[bb04609e4c960450]::util::run_in_thread_with_globals<rustc_interface[bb04609e4c960450]::util::run_in_thread_pool_with_globals<rustc_interface[bb04609e4c960450]::interface::run_compiler<(), rustc_driver_impl[c2a64f8504684822]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f0447a45d83adb47]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  62:     0x7febb3b7cec8 - <std[2a8c3cd46992084f]::sys::thread::unix::Thread>::new::thread_start
  63:     0x7febad497739 - <unknown>
  64:     0x7febad51bedc - <unknown>
  65:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-07-19T19_48_54-2324849.txt` to your bug report

note: rustc 1.99.0-nightly (eff8269f7 2026-07-18) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [is_sized_raw] computing whether `dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)` is `Sized`
#1 [layout_of] computing layout of `*const dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)`
#2 [layout_of] computing layout of `(*const dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)) is !null`
#3 [layout_of] computing layout of `core::ptr::non_null::NonNull<dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)>`
#4 [layout_of] computing layout of `core::ptr::unique::Unique<dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)>`
#5 [layout_of] computing layout of `alloc::boxed::Box<dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)>`
#6 [layout_of] computing layout of `alloc::boxed::Box<dyn core::ops::function::Fn(alloc::boxed::Box<dyn core::ops::function::Fn() -> &'a isize>)>`
end of query stack
warning: 2 warnings emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.F-unsafe_binders`#![feature(unsafe_binders)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions