[ICE]: try_visit_primitive() on unsafe binder
Open
@TKanX is already working on this.
Since Mar 5, 2026.
C-bug
F-unsafe_binders
I-ICE
S-bug-has-test
S-has-mcve
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
struct ThinDst {
b: unsafe<> (),
}
const fn t<const N: usize>(x: &[u8; N]) -> &ThinDst {
unsafe { std::mem::transmute(x.as_ptr()) }
}
const C1: &ThinDst = t(b"d");
original:
#![feature(unsafe_binders)]
#[warn(incomplete_features)]
struct ThinDst {
b: unsafe<> (),
}
const fn t<const N: usize>(x: &[u8; N]) -> &ThinDst {
unsafe { std::mem::transmute(x.as_ptr()) }
}
const C1: &ThinDst = t(b"d");
fn main() {}
Version information
rustc 1.96.0-nightly (d2218f5f5 2026-03-03)
binary: rustc
commit-hash: d2218f5f5ca3f502772ec4cb69fc2ee44e096512
commit-date: 2026-03-03
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0
Possibly related line of code:
https://github.com/rust-lang/rust/blob/d2218f5f5ca3f502772ec4cb69fc2ee44e096512/compiler/rustc_const_eval/src/interpret/validity.rs#L767-L779
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0658]: unsafe binder types are experimental
--> /tmp/icemaker_global_tempdir.ZAmCjcldfpKL/rustc_testrunner_tmpdir_reporting.gNrmZM9WnH59/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-03-03; consider upgrading it if it is out of date
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.ZAmCjcldfpKL/rustc_testrunner_tmpdir_reporting.gNrmZM9WnH59/mvce.rs:9:30
|
9 | const C1: &ThinDst = t(b"d");
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.ZAmCjcldfpKL/rustc_testrunner_tmpdir_reporting.gNrmZM9WnH59/mvce.rs`
thread 'rustc' (616478) panicked at /rustc-dev/d2218f5f5ca3f502772ec4cb69fc2ee44e096512/compiler/rustc_const_eval/src/interpret/validity.rs:773:36:
not yet implemented: FIXME(unsafe_binder)
stack backtrace:
0: 0x7f34da362aab - <<std[76599d2169901dc8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[d5ffb84325ed5c2a]::fmt::Display>::fmt
1: 0x7f34daa228c8 - core[d5ffb84325ed5c2a]::fmt::write
2: 0x7f34da379ab6 - <std[76599d2169901dc8]::sys::stdio::unix::Stderr as std[76599d2169901dc8]::io::Write>::write_fmt
3: 0x7f34da338b88 - std[76599d2169901dc8]::panicking::default_hook::{closure#0}
4: 0x7f34da355f13 - std[76599d2169901dc8]::panicking::default_hook
5: 0x7f34d93424cc - std[76599d2169901dc8]::panicking::update_hook::<alloc[f847baa7d3d2ac55]::boxed::Box<rustc_driver_impl[ffd722fd6c32666a]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f34da3561f2 - std[76599d2169901dc8]::panicking::panic_with_hook
7: 0x7f34da338c7a - std[76599d2169901dc8]::panicking::panic_handler::{closure#0}
8: 0x7f34da32f979 - std[76599d2169901dc8]::sys::backtrace::__rust_end_short_backtrace::<std[76599d2169901dc8]::panicking::panic_handler::{closure#0}, !>
9: 0x7f34da33a6ad - __rustc[7dea9537d06e225e]::rust_begin_unwind
10: 0x7f34d6f1975c - core[d5ffb84325ed5c2a]::panicking::panic_fmt
11: 0x7f34dad8eb04 - <rustc_const_eval[3ec53bb1f97627c7]::interpret::validity::ValidityVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine>>::try_visit_primitive
12: 0x7f34dad8f8bb - <rustc_const_eval[3ec53bb1f97627c7]::interpret::validity::ValidityVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine> as rustc_const_eval[3ec53bb1f97627c7]::interpret::visitor::ValueVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine>>::visit_value
13: 0x7f34dad913d9 - <rustc_const_eval[3ec53bb1f97627c7]::interpret::validity::ValidityVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine> as rustc_const_eval[3ec53bb1f97627c7]::interpret::visitor::ValueVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine>>::walk_value
14: 0x7f34dad8f9b8 - <rustc_const_eval[3ec53bb1f97627c7]::interpret::validity::ValidityVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine> as rustc_const_eval[3ec53bb1f97627c7]::interpret::visitor::ValueVisitor<rustc_const_eval[3ec53bb1f97627c7]::const_eval::machine::CompileTimeMachine>>::visit_value
15: 0x7f34dad8d44c - rustc_const_eval[3ec53bb1f97627c7]::const_eval::eval_queries::intern_and_validate::<rustc_middle[7c9cbe436035c5a4]::mir::consts::ConstAlloc>
16: 0x7f34dbade4e8 - rustc_const_eval[3ec53bb1f97627c7]::const_eval::eval_queries::eval_to_allocation_raw_provider
17: 0x7f34dbadbb98 - rustc_query_impl[89f9236b2ac04da0]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
18: 0x7f34db71bf83 - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::DefaultCache<rustc_middle[7c9cbe436035c5a4]::ty::PseudoCanonicalInput<rustc_middle[7c9cbe436035c5a4]::mir::interpret::GlobalId>, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 24usize]>>, false>
19: 0x7f34db71b93f - rustc_query_impl[89f9236b2ac04da0]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
20: 0x7f34db71d531 - rustc_const_eval[3ec53bb1f97627c7]::const_eval::eval_queries::eval_to_const_value_raw_provider
21: 0x7f34db71d0a8 - rustc_query_impl[89f9236b2ac04da0]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
22: 0x7f34db71be87 - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::DefaultCache<rustc_middle[7c9cbe436035c5a4]::ty::PseudoCanonicalInput<rustc_middle[7c9cbe436035c5a4]::mir::interpret::GlobalId>, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 24usize]>>, false>
23: 0x7f34db71b9ff - rustc_query_impl[89f9236b2ac04da0]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
24: 0x7f34db0a5e83 - <rustc_middle[7c9cbe436035c5a4]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[7282aa5ba0febab4]::check_crate::{closure#2}>::{closure#0}
25: 0x7f34db0a54f5 - rustc_hir_analysis[7282aa5ba0febab4]::check_crate
26: 0x7f34dab69b93 - rustc_interface[400bc27e64bfd912]::passes::analysis
27: 0x7f34dbc3175c - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::SingleCache<rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 0usize]>>, false>
28: 0x7f34dbc314bb - rustc_query_impl[89f9236b2ac04da0]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
29: 0x7f34dbbeda2d - rustc_interface[400bc27e64bfd912]::interface::run_compiler::<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}
30: 0x7f34dbbd20be - std[76599d2169901dc8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[400bc27e64bfd912]::util::run_in_thread_with_globals<rustc_interface[400bc27e64bfd912]::util::run_in_thread_pool_with_globals<rustc_interface[400bc27e64bfd912]::interface::run_compiler<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
31: 0x7f34dbbd2720 - <std[76599d2169901dc8]::thread::lifecycle::spawn_unchecked<rustc_interface[400bc27e64bfd912]::util::run_in_thread_with_globals<rustc_interface[400bc27e64bfd912]::util::run_in_thread_pool_with_globals<rustc_interface[400bc27e64bfd912]::interface::run_compiler<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d5ffb84325ed5c2a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
32: 0x7f34dbbd35ac - <std[76599d2169901dc8]::sys::thread::unix::Thread>::new::thread_start
33: 0x7f34d56a598b - <unknown>
34: 0x7f34d5729a0c - <unknown>
35: 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 (d2218f5f5 2026-03-03) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `C1`
#1 [eval_to_const_value_raw] simplifying constant for the type system `C1`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.
@rustbot label +F-unsafe_binders
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.