-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
A-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
auto-reduced
#![feature(repr_simd, )]
#[repr(simd)]
struct T<const N: usize>([i32; N]);
trait SimdInsert {
type Value;
unsafe fn insert(self, index: u8, value: Self::Value) -> Self;
}
trait SimdExtract {
type Value;
unsafe fn extract(self, index: u8) -> Self::Value;
}
impl<const N: usize> SimdInsert for T<N> {
type Value = i32;
unsafe fn insert( self, index: u8, value: Self::Value) -> Self {
self
}
}
impl<const N: usize> SimdExtract for T<N> {
type Value = i32;
unsafe fn extract(self, index: u8) -> Self::Value {
self.0[index as usize]
}
}
fn main() {
let t = T([5, 6, 7, 8]);
unsafe {
let value = t.extract(2);
}
}Meta
rustc --version --verbose:
rustc 1.96.0-nightly (b41f22de2 2026-03-08)
binary: rustc
commit-hash: b41f22de2a13a0babd28771e96feef4c309f54aa
commit-date: 2026-03-08
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0
Backtrace
warning: unused variable: `index`
--> bug.rs:30:29
|
30 | unsafe fn insert( self, index: u8, value: Self::Value) -> Self {
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_index`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
warning: unused variable: `value`
--> bug.rs:30:40
|
30 | unsafe fn insert( self, index: u8, value: Self::Value) -> Self {
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_value`
warning: unused variable: `value`
--> bug.rs:51:13
|
51 | let value = t.extract(2);
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_value`
warning: trait `SimdInsert` is never used
--> bug.rs:14:7
|
14 | trait SimdInsert {
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
error: internal compiler error: /rustc-dev/b41f22de2a13a0babd28771e96feef4c309f54aa/compiler/rustc_mir_transform/src/validate.rs:81:25: broken MIR in Item(DefId(0:21 ~ bug[6dcf]::{impl#1}::extract)) (after phase change to runtime-optimized) at bb1[0]:
Projecting into SIMD type T is banned by MCP#838
--> bug.rs:39:9
|
39 | self.0[index as usize]
| ^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' (2123732) panicked at /rustc-dev/b41f22de2a13a0babd28771e96feef4c309f54aa/compiler/rustc_mir_transform/src/validate.rs:81:25:
Box<dyn Any>
stack backtrace:
0: 0x7f794cb5254b - <<std[f377252fd1978e75]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[40ef8ddb62afa269]::fmt::Display>::fmt
1: 0x7f794d215288 - core[40ef8ddb62afa269]::fmt::write
2: 0x7f794cb69556 - <std[f377252fd1978e75]::sys::stdio::unix::Stderr as std[f377252fd1978e75]::io::Write>::write_fmt
3: 0x7f794cb28638 - std[f377252fd1978e75]::panicking::default_hook::{closure#0}
4: 0x7f794cb459c3 - std[f377252fd1978e75]::panicking::default_hook
5: 0x7f794bb371bc - std[f377252fd1978e75]::panicking::update_hook::<alloc[7d80c8e5f2bc07aa]::boxed::Box<rustc_driver_impl[a7e284e8ff2767b6]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f794cb45ca2 - std[f377252fd1978e75]::panicking::panic_with_hook
7: 0x7f794bb67331 - std[f377252fd1978e75]::panicking::begin_panic::<rustc_errors[f5c90c2ffb7f3cef]::ExplicitBug>::{closure#0}
8: 0x7f794bb5fea6 - std[f377252fd1978e75]::sys::backtrace::__rust_end_short_backtrace::<std[f377252fd1978e75]::panicking::begin_panic<rustc_errors[f5c90c2ffb7f3cef]::ExplicitBug>::{closure#0}, !>
9: 0x7f794bb5fd7b - std[f377252fd1978e75]::panicking::begin_panic::<rustc_errors[f5c90c2ffb7f3cef]::ExplicitBug>
10: 0x7f794bb72981 - <rustc_errors[f5c90c2ffb7f3cef]::diagnostic::BugAbort as rustc_errors[f5c90c2ffb7f3cef]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f794c127fdc - <rustc_errors[f5c90c2ffb7f3cef]::DiagCtxtHandle>::span_bug::<rustc_span[825691e18cdd0684]::span_encoding::Span, alloc[7d80c8e5f2bc07aa]::string::String>
12: 0x7f794c14f9d6 - rustc_middle[6d7cfdcb6c95edb7]::util::bug::opt_span_bug_fmt::<rustc_span[825691e18cdd0684]::span_encoding::Span>::{closure#0}
13: 0x7f794c14fb82 - rustc_middle[6d7cfdcb6c95edb7]::ty::context::tls::with_opt::<rustc_middle[6d7cfdcb6c95edb7]::util::bug::opt_span_bug_fmt<rustc_span[825691e18cdd0684]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7f794c14082b - rustc_middle[6d7cfdcb6c95edb7]::ty::context::tls::with_context_opt::<rustc_middle[6d7cfdcb6c95edb7]::ty::context::tls::with_opt<rustc_middle[6d7cfdcb6c95edb7]::util::bug::opt_span_bug_fmt<rustc_span[825691e18cdd0684]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7f794a55e158 - rustc_middle[6d7cfdcb6c95edb7]::util::bug::span_bug_fmt::<rustc_span[825691e18cdd0684]::span_encoding::Span>
16: 0x7f794a8b38b5 - <rustc_mir_transform[a7be91beee0c6c1e]::validate::CfgChecker>::fail::<alloc[7d80c8e5f2bc07aa]::string::String>
17: 0x7f794de93a33 - <rustc_mir_transform[a7be91beee0c6c1e]::validate::Validator as rustc_mir_transform[a7be91beee0c6c1e]::pass_manager::MirPass>::run_pass
18: 0x7f794d1ffc89 - rustc_mir_transform[a7be91beee0c6c1e]::run_optimization_passes
19: 0x7f794d7d33d5 - rustc_mir_transform[a7be91beee0c6c1e]::optimized_mir
20: 0x7f794d7d3023 - rustc_query_impl[5ff32ada1adb4c7a]::query_impl::optimized_mir::invoke_provider_fn::__rust_begin_short_backtrace
21: 0x7f794d209207 - rustc_query_impl[5ff32ada1adb4c7a]::execution::try_execute_query::<rustc_middle[6d7cfdcb6c95edb7]::query::caches::DefIdCache<rustc_middle[6d7cfdcb6c95edb7]::query::erase::ErasedData<[u8; 8usize]>>, false>
22: 0x7f794d20878e - rustc_query_impl[5ff32ada1adb4c7a]::query_impl::optimized_mir::execute_query_non_incr::__rust_end_short_backtrace
23: 0x7f794def84ce - <rustc_middle[6d7cfdcb6c95edb7]::ty::context::TyCtxt>::instance_mir
24: 0x7f794defa2cb - rustc_monomorphize[980ee425a9bb6f45]::collector::items_of_instance
25: 0x7f794defa251 - rustc_query_impl[5ff32ada1adb4c7a]::query_impl::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
26: 0x7f794df6e867 - rustc_query_impl[5ff32ada1adb4c7a]::execution::try_execute_query::<rustc_middle[6d7cfdcb6c95edb7]::query::caches::DefaultCache<(rustc_middle[6d7cfdcb6c95edb7]::ty::instance::Instance, rustc_middle[6d7cfdcb6c95edb7]::mir::mono::CollectionMode), rustc_middle[6d7cfdcb6c95edb7]::query::erase::ErasedData<[u8; 32usize]>>, false>
27: 0x7f794df6e493 - rustc_query_impl[5ff32ada1adb4c7a]::query_impl::items_of_instance::execute_query_non_incr::__rust_end_short_backtrace
28: 0x7f794e713531 - rustc_monomorphize[980ee425a9bb6f45]::collector::collect_items_rec
29: 0x7f794e71531f - rustc_monomorphize[980ee425a9bb6f45]::collector::collect_items_rec
30: 0x7f794dcd9fb1 - rustc_monomorphize[980ee425a9bb6f45]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
31: 0x7f794da97879 - rustc_monomorphize[980ee425a9bb6f45]::partitioning::collect_and_partition_mono_items
32: 0x7f794da97516 - rustc_query_impl[5ff32ada1adb4c7a]::query_impl::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
33: 0x7f794e47f8a4 - rustc_query_impl[5ff32ada1adb4c7a]::execution::try_execute_query::<rustc_middle[6d7cfdcb6c95edb7]::query::caches::SingleCache<rustc_middle[6d7cfdcb6c95edb7]::query::erase::ErasedData<[u8; 24usize]>>, false>
34: 0x7f794e47f63c - rustc_query_impl[5ff32ada1adb4c7a]::query_impl::collect_and_partition_mono_items::execute_query_non_incr::__rust_end_short_backtrace
35: 0x7f794e56a639 - rustc_codegen_ssa[1989ede88636deb3]::base::codegen_crate::<rustc_codegen_llvm[126abe350048c0c7]::LlvmCodegenBackend>
36: 0x7f794e56a34d - <rustc_codegen_llvm[126abe350048c0c7]::LlvmCodegenBackend as rustc_codegen_ssa[1989ede88636deb3]::traits::backend::CodegenBackend>::codegen_crate
37: 0x7f794e434d7a - <rustc_interface[5f8c59f625471e6f]::queries::Linker>::codegen_and_build_linker
38: 0x7f794e42f841 - rustc_interface[5f8c59f625471e6f]::interface::run_compiler::<(), rustc_driver_impl[a7e284e8ff2767b6]::run_compiler::{closure#0}>::{closure#1}
39: 0x7f794e462a7e - std[f377252fd1978e75]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5f8c59f625471e6f]::util::run_in_thread_with_globals<rustc_interface[5f8c59f625471e6f]::util::run_in_thread_pool_with_globals<rustc_interface[5f8c59f625471e6f]::interface::run_compiler<(), rustc_driver_impl[a7e284e8ff2767b6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
40: 0x7f794e463320 - <std[f377252fd1978e75]::thread::lifecycle::spawn_unchecked<rustc_interface[5f8c59f625471e6f]::util::run_in_thread_with_globals<rustc_interface[5f8c59f625471e6f]::util::run_in_thread_pool_with_globals<rustc_interface[5f8c59f625471e6f]::interface::run_compiler<(), rustc_driver_impl[a7e284e8ff2767b6]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[40ef8ddb62afa269]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
41: 0x7f794e4641ac - <std[f377252fd1978e75]::sys::thread::unix::Thread>::new::thread_start
42: 0x7f7947f9d609 - start_thread
at /build/glibc-B3wQXB/glibc-2.31/nptl/pthread_create.c:477:8
43: 0x7f7947ec2353 - clone
at /build/glibc-B3wQXB/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95:0
44: 0x0 - <unknown>
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/test/rustc-ice-2026-03-10T03_34_29-2123628.txt` to your bug report
note: rustc 1.96.0-nightly (b41f22de2 2026-03-08) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at bug.rs:36:1: 36:42>::extract`
#1 [items_of_instance] collecting items used by `<impl at bug.rs:36:1: 36:42>::extract`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 1 previous error; 4 warnings emitted
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.