-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Description
With the latest version of the portable-simd feature implemented in #151775, Simd<T, N> should trigger a post-monomorphization error for any N > 64.
For instance:
rust/library/portable-simd/crates/core_simd/src/select.rs
Lines 73 to 82 in b71ff51
| impl<T, const N: usize> Select<Simd<T, N>> for u64 | |
| where | |
| T: SimdElement, | |
| { | |
| #[inline] | |
| fn select(self, true_values: Simd<T, N>, false_values: Simd<T, N>) -> Simd<T, N> { | |
| const { | |
| assert!(N <= 64, "number of elements can't be greater than 64"); | |
| } | |
However, presumably due to however rustc_simd_monomorphize_lane_limit is implemented, the checks aren't perfect and an ICE is possible.
rust/library/portable-simd/crates/core_simd/src/vector.rs
Lines 106 to 110 in b71ff51
| #[repr(simd, packed)] | |
| #[rustc_simd_monomorphize_lane_limit = "64"] | |
| pub struct Simd<T, const N: usize>([T; N]) | |
| where | |
| T: SimdElement; |
I'm not sure if rustc_simd_monomorphize_lane_limit is what directly triggers the ICE, or if some ABI computation critically relies on rustc_simd_monomorphize_lane_limit correctly checking the limit (and then triggers the ICE when the checks don't catch something).
Code
I found this on Rust Playground (which, at the time of writing, uses nightly 2026-02-04 db3e99bbab28c6ca778b): https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=4681cc6713e9fccd811958c8237ff73b
#![feature(portable_simd)]
fn main() {
if false {
let _ = core::simd::Simd::<u8, 256>::splat(0);
}
}Meta
rustc version: whatever Rust Playground uses as of today. (nightly-1.95.0 (2026-02-04 db3e99bbab28c6ca778b) is the info it shows. The target is x86_64-unknown-linux-gnu AFAIK.)
Error output
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: ABI computation failure should lead to compilation failure
|
= note: delayed at /rustc-dev/db3e99bbab28c6ca778b13222becdea54533d908/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs:164:19
Backtrace
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<&str>
4: rustc_monomorphize::mono_checks::check_mono_item
5: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mono_item::make_query_vtable::{closure#1}::{closure#0}, rustc_middle::query::erase::ErasedData<[u8; 0]>>
6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::SemiDynamicQueryDispatcher<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::instance::Instance, rustc_middle::query::erase::ErasedData<[u8; 0]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
7: rustc_query_impl::query_impl::check_mono_item::get_query_non_incr::__rust_end_short_backtrace
8: rustc_monomorphize::collector::items_of_instance
9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::items_of_instance::make_query_vtable::{closure#1}::{closure#0}, rustc_middle::query::erase::ErasedData<[u8; 32]>>
10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::SemiDynamicQueryDispatcher<rustc_query_system::query::caches::DefaultCache<(rustc_middle::ty::instance::Instance, rustc_middle::mir::mono::CollectionMode), rustc_middle::query::erase::ErasedData<[u8; 32]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
11: rustc_query_impl::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
12: rustc_monomorphize::collector::collect_items_rec
13: rustc_monomorphize::collector::collect_items_rec
14: rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}
15: rustc_monomorphize::partitioning::collect_and_partition_mono_items
16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_and_partition_mono_items::make_query_vtable::{closure#1}::{closure#0}, rustc_middle::query::erase::ErasedData<[u8; 24]>>
17: <rustc_query_impl::query_impl::collect_and_partition_mono_items::make_query_vtable::{closure#1} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::SemiDynamicQueryDispatcher<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 24]>>, {rustc_query_impl::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
19: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
20: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
21: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
22: <rustc_interface::queries::Linker>::codegen_and_build_linker
23: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
24: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
25: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
26: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
27: <std::sys::thread::unix::Thread>::new::thread_start
28: <unknown>
29: clone