rust-lang / rust-lang/rust

[ICE]: `not immediate: OperandRef`

Open
#154,904 4 comments 0 reactions 1 assignee View on GitHub

@zachs18 is already working on this.

Since Aug 25, 2026.

A-inline-assembly C-bug F-never_type I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: --crate-type=lib
#![feature(never_type)]
pub fn invoke(pc_section: &[!]) {
    unsafe { std::arch::asm!("/* {} */", in(reg)pc_section[0]) }
}

original:

#![feature(never_type)]
pub fn invoke(pc_section: &[!]) {
    unsafe { std::arch::asm!("/* {} */", in(reg)pc_section[0]) }
}

fn main() {}

Version information

rustc 1.96.0-nightly (fff9e4432 2026-04-06)
binary: rustc
commit-hash: fff9e4432233df859e4fadb30ab7f0eda22580a6
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/fff9e4432233df859e4fadb30ab7f0eda22580a6/compiler/rustc_codegen_ssa/src/mir/operand.rs#L255-L267

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: unreachable expression
 --> /tmp/icemaker_global_tempdir.5Evymrx7HUWq/rustc_testrunner_tmpdir_reporting.0uNSLS5yKoU9/mvce.rs:3:14
  |
3 |     unsafe { std::arch::asm!("/* {} */", in(reg)pc_section[0]) }
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^
  |              |                                  |
  |              |                                  any code following this expression is unreachable
  |              unreachable expression
  |
  = note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/fff9e4432233df859e4fadb30ab7f0eda22580a6/compiler/rustc_codegen_ssa/src/mir/operand.rs:261:18: not immediate: OperandRef(ZeroSized @ TyAndLayout { ty: !, layout: Layout { size: Size(0 bytes), align: AbiAlign { abi: Align(1 bytes) }, backend_repr: Memory { sized: true }, fields: Primitive, largest_niche: None, uninhabited: true, variants: Empty, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), randomization_seed: 0 } })


thread 'rustc' (480724) panicked at /rustc-dev/fff9e4432233df859e4fadb30ab7f0eda22580a6/compiler/rustc_codegen_ssa/src/mir/operand.rs:261:18:
Box<dyn Any>
stack backtrace:
   0:     0x7f9bc6dda35b - <<std[8c96247e38178e87]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[bb53695d08591fa6]::fmt::Display>::fmt
   1:     0x7f9bc741ddc8 - core[bb53695d08591fa6]::fmt::write
   2:     0x7f9bc6df1626 - <std[8c96247e38178e87]::sys::stdio::unix::Stderr as std[8c96247e38178e87]::io::Write>::write_fmt
   3:     0x7f9bc6db0658 - std[8c96247e38178e87]::panicking::default_hook::{closure#0}
   4:     0x7f9bc6dcd9c3 - std[8c96247e38178e87]::panicking::default_hook
   5:     0x7f9bc5dd494c - std[8c96247e38178e87]::panicking::update_hook::<alloc[ccb441010e164770]::boxed::Box<rustc_driver_impl[81e2fde32905c39d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f9bc6dcdca2 - std[8c96247e38178e87]::panicking::panic_with_hook
   7:     0x7f9bc5e04921 - std[8c96247e38178e87]::panicking::begin_panic::<rustc_errors[f5d3ddd97d961da3]::ExplicitBug>::{closure#0}
   8:     0x7f9bc5dfd386 - std[8c96247e38178e87]::sys::backtrace::__rust_end_short_backtrace::<std[8c96247e38178e87]::panicking::begin_panic<rustc_errors[f5d3ddd97d961da3]::ExplicitBug>::{closure#0}, !>
   9:     0x7f9bc5dfb188 - std[8c96247e38178e87]::panicking::begin_panic::<rustc_errors[f5d3ddd97d961da3]::ExplicitBug>
  10:     0x7f9bc5e0ff61 - <rustc_errors[f5d3ddd97d961da3]::diagnostic::BugAbort as rustc_errors[f5d3ddd97d961da3]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f9bc63ec199 - rustc_middle[6be30f081655eb95]::util::bug::opt_span_bug_fmt::<rustc_span[80bda612cc6ab068]::span_encoding::Span>::{closure#0}
  12:     0x7f9bc63ec322 - rustc_middle[6be30f081655eb95]::ty::context::tls::with_opt::<rustc_middle[6be30f081655eb95]::util::bug::opt_span_bug_fmt<rustc_span[80bda612cc6ab068]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f9bc63dc8db - rustc_middle[6be30f081655eb95]::ty::context::tls::with_context_opt::<rustc_middle[6be30f081655eb95]::ty::context::tls::with_opt<rustc_middle[6be30f081655eb95]::util::bug::opt_span_bug_fmt<rustc_span[80bda612cc6ab068]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f9bc350cec4 - rustc_middle[6be30f081655eb95]::util::bug::bug_fmt
  15:     0x7f9bc88874a7 - <rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::builder::GenericBuilder<rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::context::FullCx> as rustc_codegen_ssa[524a24c60837220e]::traits::asm::AsmBuilderMethods>::codegen_inline_asm
  16:     0x7f9bc886b0a7 - rustc_codegen_ssa[524a24c60837220e]::mir::codegen_mir::<rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::builder::GenericBuilder<rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::context::FullCx>>
  17:     0x7f9bc74d855f - rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::base::compile_codegen_unit::module_codegen
  18:     0x7f9bc874d144 - <rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::LlvmCodegenBackend as rustc_codegen_ssa[524a24c60837220e]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  19:     0x7f9bc8748c87 - rustc_codegen_ssa[524a24c60837220e]::base::codegen_crate::<rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::LlvmCodegenBackend>
  20:     0x7f9bc8746dcd - <rustc_codegen_llvm[9ed2f6cbf1cc5fb8]::LlvmCodegenBackend as rustc_codegen_ssa[524a24c60837220e]::traits::backend::CodegenBackend>::codegen_crate
  21:     0x7f9bc864f9f2 - <rustc_interface[a07b2b9cb0b39108]::queries::Linker>::codegen_and_build_linker
  22:     0x7f9bc8649b97 - rustc_interface[a07b2b9cb0b39108]::interface::run_compiler::<(), rustc_driver_impl[81e2fde32905c39d]::run_compiler::{closure#0}>::{closure#1}
  23:     0x7f9bc862effe - std[8c96247e38178e87]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a07b2b9cb0b39108]::util::run_in_thread_with_globals<rustc_interface[a07b2b9cb0b39108]::util::run_in_thread_pool_with_globals<rustc_interface[a07b2b9cb0b39108]::interface::run_compiler<(), rustc_driver_impl[81e2fde32905c39d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x7f9bc862f8a0 - <std[8c96247e38178e87]::thread::lifecycle::spawn_unchecked<rustc_interface[a07b2b9cb0b39108]::util::run_in_thread_with_globals<rustc_interface[a07b2b9cb0b39108]::util::run_in_thread_pool_with_globals<rustc_interface[a07b2b9cb0b39108]::interface::run_compiler<(), rustc_driver_impl[81e2fde32905c39d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[bb53695d08591fa6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f9bc86307ac - <std[8c96247e38178e87]::sys::thread::unix::Thread>::new::thread_start
  26:     0x7f9bc20a597a - <unknown>
  27:     0x7f9bc21292bc - <unknown>
  28:                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: rustc 1.96.0-nightly (fff9e4432 2026-04-06) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack
error: aborting due to 1 previous error; 1 warning emitted


@rustbot label +F-never_type

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.