Skip to content

ICE: improper ctypes: extern unsafe binders #149719

@matthiaskrgr

Description

@matthiaskrgr

code:

#![feature(unsafe_binders)]
unsafe extern {
    fn exit_2(_x: unsafe<'a> &'a ()) ;

}
fn main() {}

Version information

rustc 1.94.0-nightly (fbab541a7 2025-12-06)
binary: rustc
commit-hash: fbab541a7ad1c22fc51783d03c7d75fa577f5633
commit-date: 2025-12-06
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.5

Possibly related line of code:

ty::Param(..) | ty::Alias(ty::Projection | ty::Inherent, ..)
if state.can_expect_ty_params() =>
{
FfiSafe
}
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),
ty::Param(..)
| ty::Alias(ty::Projection | ty::Inherent | ty::Free, ..)
| ty::Infer(..)
| ty::Bound(..)
| ty::Error(_)

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.tKW9U9H846f8/rustc_testrunner_tmpdir_reporting.MKyXcvUuo4CJ/mvce.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 `exit_2` is never used
 --> /tmp/icemaker_global_tempdir.tKW9U9H846f8/rustc_testrunner_tmpdir_reporting.MKyXcvUuo4CJ/mvce.rs:3:8
  |
3 |     fn exit_2(_x: unsafe<'a> &'a ());
  |        ^^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default


thread 'rustc' (1663257) panicked at compiler/rustc_lint/src/types/improper_ctypes.rs:672:36:
not yet implemented: FIXME(unsafe_binder)
stack backtrace:
   0:     0x7faa1c684f63 - <<std[30d1384522680fe8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[21868c0c5a10a1a4]::fmt::Display>::fmt
   1:     0x7faa1ce106c8 - core[21868c0c5a10a1a4]::fmt::write
   2:     0x7faa1c69b686 - <std[30d1384522680fe8]::sys::stdio::unix::Stderr as std[30d1384522680fe8]::io::Write>::write_fmt
   3:     0x7faa1c65b728 - std[30d1384522680fe8]::panicking::default_hook::{closure#0}
   4:     0x7faa1c678e33 - std[30d1384522680fe8]::panicking::default_hook
   5:     0x7faa1b6d70e7 - std[30d1384522680fe8]::panicking::update_hook::<alloc[fe25149d2e0f3b49]::boxed::Box<rustc_driver_impl[ee712ad3fe927a50]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7faa1c679112 - std[30d1384522680fe8]::panicking::panic_with_hook
   7:     0x7faa1c65b81a - std[30d1384522680fe8]::panicking::panic_handler::{closure#0}
   8:     0x7faa1c6528a9 - std[30d1384522680fe8]::sys::backtrace::__rust_end_short_backtrace::<std[30d1384522680fe8]::panicking::panic_handler::{closure#0}, !>
   9:     0x7faa1c65d39d - __rustc[4a386ae28c721ec5]::rust_begin_unwind
  10:     0x7faa19b3c42c - core[21868c0c5a10a1a4]::panicking::panic_fmt
  11:     0x7faa1e8833f5 - <rustc_lint[a598aad53486b051]::types::improper_ctypes::ImproperCTypesVisitor>::visit_type.cold
  12:     0x7faa1d287fb6 - <rustc_lint[a598aad53486b051]::types::improper_ctypes::ImproperCTypesVisitor>::check_type
  13:     0x7faa1d287c4c - <rustc_lint[a598aad53486b051]::types::improper_ctypes::ImproperCTypesLint>::check_foreign_fn
  14:     0x7faa1d41787f - <rustc_lint[a598aad53486b051]::late::LateContextAndPass<rustc_lint[a598aad53486b051]::BuiltinCombinedModuleLateLintPass> as rustc_hir[91393a13b1bdc727]::intravisit::Visitor>::visit_nested_item
  15:     0x7faa1d4154cc - rustc_lint[a598aad53486b051]::lint_mod
  16:     0x7faa1d415089 - rustc_query_impl[6539629e9b074ede]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6539629e9b074ede]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[46cb312bf8ccc4ab]::query::erase::Erased<[u8; 0usize]>>
  17:     0x7faa1dbb06f1 - rustc_query_system[98fd9767c01187d]::query::plumbing::try_execute_query::<rustc_query_impl[6539629e9b074ede]::DynamicConfig<rustc_query_system[98fd9767c01187d]::query::caches::DefaultCache<rustc_span[2b8dbcee9da39f6c]::def_id::LocalModDefId, rustc_middle[46cb312bf8ccc4ab]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6539629e9b074ede]::plumbing::QueryCtxt, false>
  18:     0x7faa1dbac5bd - rustc_query_impl[6539629e9b074ede]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  19:     0x7faa1dbac150 - rustc_lint[a598aad53486b051]::late::check_crate::{closure#1}
  20:     0x7faa1dbabd3a - rustc_lint[a598aad53486b051]::late::check_crate
  21:     0x7faa1d070748 - rustc_interface[abf69827c14388d7]::passes::analysis
  22:     0x7faa1d06fedb - rustc_query_impl[6539629e9b074ede]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6539629e9b074ede]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[46cb312bf8ccc4ab]::query::erase::Erased<[u8; 0usize]>>
  23:     0x7faa1df5ab20 - rustc_query_system[98fd9767c01187d]::query::plumbing::try_execute_query::<rustc_query_impl[6539629e9b074ede]::DynamicConfig<rustc_query_system[98fd9767c01187d]::query::caches::SingleCache<rustc_middle[46cb312bf8ccc4ab]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6539629e9b074ede]::plumbing::QueryCtxt, false>
  24:     0x7faa1df5a776 - rustc_query_impl[6539629e9b074ede]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7faa1e14c750 - <rustc_interface[abf69827c14388d7]::passes::create_and_enter_global_ctxt<core[21868c0c5a10a1a4]::option::Option<rustc_interface[abf69827c14388d7]::queries::Linker>, rustc_driver_impl[ee712ad3fe927a50]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[21868c0c5a10a1a4]::ops::function::FnOnce<(&rustc_session[cbac929be9e0488c]::session::Session, rustc_middle[46cb312bf8ccc4ab]::ty::context::CurrentGcx, alloc[fe25149d2e0f3b49]::sync::Arc<rustc_data_structures[bd3d9d7ab9b00a56]::jobserver::Proxy>, &std[30d1384522680fe8]::sync::once_lock::OnceLock<rustc_middle[46cb312bf8ccc4ab]::ty::context::GlobalCtxt>, &rustc_data_structures[bd3d9d7ab9b00a56]::sync::worker_local::WorkerLocal<rustc_middle[46cb312bf8ccc4ab]::arena::Arena>, &rustc_data_structures[bd3d9d7ab9b00a56]::sync::worker_local::WorkerLocal<rustc_hir[91393a13b1bdc727]::Arena>, rustc_driver_impl[ee712ad3fe927a50]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  26:     0x7faa1df94405 - rustc_interface[abf69827c14388d7]::interface::run_compiler::<(), rustc_driver_impl[ee712ad3fe927a50]::run_compiler::{closure#0}>::{closure#1}
  27:     0x7faa1df10916 - std[30d1384522680fe8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[abf69827c14388d7]::util::run_in_thread_with_globals<rustc_interface[abf69827c14388d7]::util::run_in_thread_pool_with_globals<rustc_interface[abf69827c14388d7]::interface::run_compiler<(), rustc_driver_impl[ee712ad3fe927a50]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  28:     0x7faa1df106e9 - <std[30d1384522680fe8]::thread::lifecycle::spawn_unchecked<rustc_interface[abf69827c14388d7]::util::run_in_thread_with_globals<rustc_interface[abf69827c14388d7]::util::run_in_thread_pool_with_globals<rustc_interface[abf69827c14388d7]::interface::run_compiler<(), rustc_driver_impl[ee712ad3fe927a50]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[21868c0c5a10a1a4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:     0x7faa1df0eb38 - <std[30d1384522680fe8]::sys::thread::unix::Thread>::new::thread_start
  30:     0x7faa178969cb - <unknown>
  31:     0x7faa1791aa0c - <unknown>
  32:                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: rustc 1.94.0-nightly (fbab541a7 2025-12-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
warning: 2 warnings emitted


@rustbot label +F-unsafe_binders

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-unsafe_binders`#![feature(unsafe_binders)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions