rust-lang / rust-lang/rust

[ICE]: ptr::null with unsafe binder

Open
#154,871 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-unsafe_binders I-ICE S-bug-has-test S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

struct Struct {
    b: unsafe<> (),
}
fn main() {
    std::ptr::null::<Struct>;
}

original:

#![feature(unsafe_binders)]
struct Struct {
    b: unsafe<> (),
}
fn main() {
    std::ptr::null::<Struct>;
}

Version information

rustc 1.96.0-nightly (c2efcc4ae 2026-04-06)
binary: rustc
commit-hash: c2efcc4ae006a6b2761cb42572fc9cee0d1ce4af
commit-date: 2026-04-06
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Possibly related line of code:
https://github.com/rust-lang/rust/blob/c2efcc4ae006a6b2761cb42572fc9cee0d1ce4af/compiler/rustc_trait_selection/src/traits/project.rs#L1123-L1135

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

Program output

error[E0658]: unsafe binder types are experimental
 --> /tmp/icemaker_global_tempdir.A6IhLPTBdYWO/rustc_testrunner_tmpdir_reporting.6KgdE5XcBCgS/mvce.rs:2:8
  |
2 |     b: unsafe<> (),
  |        ^^^^^^^^^^^
  |
  = note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information
  = help: add `#![feature(unsafe_binders)]` to the crate attributes to enable
  = note: this compiler was built on 2026-04-06; consider upgrading it if it is out of date


thread 'rustc' (445532) panicked at /rustc-dev/c2efcc4ae006a6b2761cb42572fc9cee0d1ce4af/compiler/rustc_trait_selection/src/traits/project.rs:1129:52:
not yet implemented: FIXME(unsafe_binder)
stack backtrace:
   0:     0x7f0edcbb66ab - <<std[8eed7d2a0d2e32a7]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c3b3818c781903d6]::fmt::Display>::fmt
   1:     0x7f0edd21d748 - core[c3b3818c781903d6]::fmt::write
   2:     0x7f0edcbcd976 - <std[8eed7d2a0d2e32a7]::sys::stdio::unix::Stderr as std[8eed7d2a0d2e32a7]::io::Write>::write_fmt
   3:     0x7f0edcb8c9a8 - std[8eed7d2a0d2e32a7]::panicking::default_hook::{closure#0}
   4:     0x7f0edcba9d13 - std[8eed7d2a0d2e32a7]::panicking::default_hook
   5:     0x7f0edbbb155c - std[8eed7d2a0d2e32a7]::panicking::update_hook::<alloc[f403ee7a715222b6]::boxed::Box<rustc_driver_impl[7e67e524f2e0558b]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0edcba9ff2 - std[8eed7d2a0d2e32a7]::panicking::panic_with_hook
   7:     0x7f0edcb8ca9a - std[8eed7d2a0d2e32a7]::panicking::panic_handler::{closure#0}
   8:     0x7f0edcb837a9 - std[8eed7d2a0d2e32a7]::sys::backtrace::__rust_end_short_backtrace::<std[8eed7d2a0d2e32a7]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f0edcb8e4cd - __rustc[1c0edf6a00b737dc]::rust_begin_unwind
  10:     0x7f0ed9696bfc - core[c3b3818c781903d6]::panicking::panic_fmt
  11:     0x7f0edd45449e - rustc_trait_selection[11b0d89c7a99abb7]::traits::project::opt_normalize_projection_term
  12:     0x7f0edd4563a3 - <rustc_infer[ebc771a24fe05da5]::infer::InferCtxt>::commit_if_ok::<rustc_trait_selection[11b0d89c7a99abb7]::traits::project::ProjectAndUnifyResult, rustc_infer[ebc771a24fe05da5]::traits::project::MismatchedProjectionTypes, rustc_trait_selection[11b0d89c7a99abb7]::traits::project::poly_project_and_unify_term::{closure#0}>
  13:     0x7f0edd78c79a - <rustc_trait_selection[11b0d89c7a99abb7]::traits::select::SelectionContext>::evaluate_predicate_recursively
  14:     0x7f0edd78ee3d - <rustc_trait_selection[11b0d89c7a99abb7]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  15:     0x7f0edd779dc2 - <rustc_trait_selection[11b0d89c7a99abb7]::traits::select::SelectionContext>::evaluate_root_obligation
  16:     0x7f0edd777f38 - rustc_traits[606884767d5c0f75]::evaluate_obligation::evaluate_obligation
  17:     0x7f0edd777887 - rustc_query_impl[f409b05e3d872181]::query_impl::evaluate_obligation::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7f0edd7769e8 - rustc_query_impl[f409b05e3d872181]::execution::try_execute_query::<rustc_middle[165f22ec1c9787f3]::query::caches::DefaultCache<rustc_type_ir[85c4afa899d1a1b6]::canonical::CanonicalQueryInput<rustc_middle[165f22ec1c9787f3]::ty::context::TyCtxt, rustc_middle[165f22ec1c9787f3]::ty::ParamEnvAnd<rustc_middle[165f22ec1c9787f3]::ty::predicate::Predicate>>, rustc_middle[165f22ec1c9787f3]::query::erase::ErasedData<[u8; 2usize]>>, false>
  19:     0x7f0edd776679 - rustc_query_impl[f409b05e3d872181]::query_impl::evaluate_obligation::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7f0edd9b0bbd - <rustc_trait_selection[11b0d89c7a99abb7]::traits::fulfill::FulfillProcessor as rustc_data_structures[cae841260e08523c]::obligation_forest::ObligationProcessor>::process_obligation
  21:     0x7f0edd206cd6 - <rustc_data_structures[cae841260e08523c]::obligation_forest::ObligationForest<rustc_trait_selection[11b0d89c7a99abb7]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[11b0d89c7a99abb7]::traits::fulfill::FulfillProcessor>
  22:     0x7f0ede4dabe1 - rustc_hir_typeck[2782182a00a8d9e]::typeck_with_inspect::{closure#0}
  23:     0x7f0ede4d9470 - rustc_query_impl[f409b05e3d872181]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7f0edd2bbe66 - rustc_query_impl[f409b05e3d872181]::execution::try_execute_query::<rustc_data_structures[cae841260e08523c]::vec_cache::VecCache<rustc_span[70fc2dc825ee8976]::def_id::LocalDefId, rustc_middle[165f22ec1c9787f3]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[165f22ec1c9787f3]::dep_graph::graph::DepNodeIndex>, false>
  25:     0x7f0edd2bb743 - rustc_query_impl[f409b05e3d872181]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  26:     0x7f0edda19b6c - <rustc_middle[165f22ec1c9787f3]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[13c6348c6cd39757]::check_crate::{closure#1}>::{closure#0}
  27:     0x7f0edda19565 - rustc_hir_analysis[13c6348c6cd39757]::check_crate
  28:     0x7f0edd2b8561 - rustc_interface[3d73cd67649ddf73]::passes::analysis
  29:     0x7f0ede445149 - rustc_query_impl[f409b05e3d872181]::execution::try_execute_query::<rustc_middle[165f22ec1c9787f3]::query::caches::SingleCache<rustc_middle[165f22ec1c9787f3]::query::erase::ErasedData<[u8; 0usize]>>, false>
  30:     0x7f0ede444db5 - rustc_query_impl[f409b05e3d872181]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f0ede46c15e - rustc_interface[3d73cd67649ddf73]::interface::run_compiler::<(), rustc_driver_impl[7e67e524f2e0558b]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7f0ede41a03e - std[8eed7d2a0d2e32a7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[3d73cd67649ddf73]::util::run_in_thread_with_globals<rustc_interface[3d73cd67649ddf73]::util::run_in_thread_pool_with_globals<rustc_interface[3d73cd67649ddf73]::interface::run_compiler<(), rustc_driver_impl[7e67e524f2e0558b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7f0ede41a8e0 - <std[8eed7d2a0d2e32a7]::thread::lifecycle::spawn_unchecked<rustc_interface[3d73cd67649ddf73]::util::run_in_thread_with_globals<rustc_interface[3d73cd67649ddf73]::util::run_in_thread_pool_with_globals<rustc_interface[3d73cd67649ddf73]::interface::run_compiler<(), rustc_driver_impl[7e67e524f2e0558b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c3b3818c781903d6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f0ede41b7ec - <std[8eed7d2a0d2e32a7]::sys::thread::unix::Thread>::new::thread_start
  35:     0x7f0ed7ea097a - <unknown>
  36:     0x7f0ed7f242bc - <unknown>
  37:                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.96.0-nightly (c2efcc4ae 2026-04-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `Struct: core::ptr::metadata::Thin`
#1 [typeck_root] type-checking `main`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

@rustbot label +F-unsafe_binders

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the reduced a.rs example using the reported nightly compiler. Start at compiler/rustc_trait_selection/src/traits/project.rs lines 1123-1135 and the panic in compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs:700; done means this unsafe-binder case reports an appropriate compiler error or completes without an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.