Skip to content

ICE unpretty-printing c_variadic #147409

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zunpretty=thir-tree --crate-type=lib
#![feature(c_variadic)]
unsafe extern "C" fn foo(_: (), ...) {}

original:

#![feature(c_variadic)]
unsafe extern "C" fn foo(_: (), ...) {}

Version information

rustc 1.92.0-nightly (8111a2d6d 2025-10-06)
binary: rustc
commit-hash: 8111a2d6da405e9684a8a83c2c9d69036bf23f12
commit-date: 2025-10-06
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.2

Possibly related line of code:

}
fn print_pat_kind(&mut self, pat_kind: &PatKind<'tcx>, depth_lvl: usize) {
print_indented!(self, "kind: PatKind {", depth_lvl);
match pat_kind {
PatKind::Missing => unreachable!(),
PatKind::Wild => {
print_indented!(self, "Wild", depth_lvl + 1);
}
PatKind::Never => {
print_indented!(self, "Never", depth_lvl + 1);
}

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

Program output

warning: function `foo` is never used
 --> /tmp/icemaker_global_tempdir.8hd3231DSQ7F/rustc_testrunner_tmpdir_reporting.T8tRFQYfH1Lj/mvce.rs:2:22
  |
2 | unsafe extern "C" fn foo(_: (), ...) {}
  |                      ^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: `extern` fn uses type `()`, which is not FFI-safe
 --> /tmp/icemaker_global_tempdir.8hd3231DSQ7F/rustc_testrunner_tmpdir_reporting.T8tRFQYfH1Lj/mvce.rs:2:29
  |
2 | unsafe extern "C" fn foo(_: (), ...) {}
  |                             ^^ not FFI-safe
  |
  = help: consider using a struct instead
  = note: tuples have unspecified layout
  = note: `#[warn(improper_ctypes_definitions)]` on by default


thread 'rustc' (1183049) panicked at compiler/rustc_mir_build/src/thir/print.rs:692:33:
internal error: entered unreachable code
stack backtrace:
   0:     0x7f6e923c5933 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h9d493bf7fa709445
   1:     0x7f6e92a01fbc - core::fmt::write::hc6c08c30b818d85a
   2:     0x7f6e9237a333 - std::io::Write::write_fmt::h1a8070f00bb47620
   3:     0x7f6e9238b8f2 - std::sys::backtrace::BacktraceLock::print::he5d95542d2b86573
   4:     0x7f6e92391969 - std::panicking::default_hook::{{closure}}::hf509239352864b0b
   5:     0x7f6e92391493 - std::panicking::default_hook::h41a205ba0e6bad2c
   6:     0x7f6e913a6af7 - std[5bd9112d56c9e542]::panicking::update_hook::<alloc[8dd70e2de2dd10a]::boxed::Box<rustc_driver_impl[799d235ef8173497]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f6e92391d8f - std::panicking::panic_with_hook::h423ed9a60c1bb0bf
   8:     0x7f6e92391b16 - std::panicking::panic_handler::{{closure}}::h380789c533e4be75
   9:     0x7f6e9238ba39 - std::sys::backtrace::__rust_end_short_backtrace::h6043c6eeb7d07ee0
  10:     0x7f6e9236c56d - __rustc[79156e1635b10208]::rust_begin_unwind
  11:     0x7f6e8f3b7230 - core::panicking::panic_fmt::h566dcbe782a35b3a
  12:     0x7f6e8ed30afc - core::panicking::panic::h89c36c3165d18322
  13:     0x7f6e91a6c086 - <rustc_mir_build[d887d91fdf65e771]::thir::print::ThirPrinter>::print_pat
  14:     0x7f6e91a71c5f - rustc_mir_build[d887d91fdf65e771]::thir::print::thir_tree
  15:     0x7f6e913b1133 - rustc_driver_impl[799d235ef8173497]::pretty::print
  16:     0x7f6e913a93cd - rustc_interface[8b029a4f81d57bf6]::passes::create_and_enter_global_ctxt::<(), rustc_driver_impl[799d235ef8173497]::run_compiler::{closure#0}::{closure#1}>::{closure#2}::{closure#0}
  17:     0x7f6e913ad3cd - <rustc_interface[8b029a4f81d57bf6]::passes::create_and_enter_global_ctxt<(), rustc_driver_impl[799d235ef8173497]::run_compiler::{closure#0}::{closure#1}>::{closure#2} as core[16b3fef4fa94656]::ops::function::FnOnce<(&rustc_session[62811e3f1498e52e]::session::Session, rustc_middle[244f91c2aa28f1b4]::ty::context::CurrentGcx, alloc[8dd70e2de2dd10a]::sync::Arc<rustc_data_structures[70eb418aee26b76d]::jobserver::Proxy>, &std[5bd9112d56c9e542]::sync::once_lock::OnceLock<rustc_middle[244f91c2aa28f1b4]::ty::context::GlobalCtxt>, &rustc_data_structures[70eb418aee26b76d]::sync::worker_local::WorkerLocal<rustc_middle[244f91c2aa28f1b4]::arena::Arena>, &rustc_data_structures[70eb418aee26b76d]::sync::worker_local::WorkerLocal<rustc_hir[b3b90dd82afea593]::Arena>, rustc_driver_impl[799d235ef8173497]::run_compiler::{closure#0}::{closure#1})>>::call_once::{shim:vtable#0}
  18:     0x7f6e93bf8b20 - rustc_interface[8b029a4f81d57bf6]::interface::run_compiler::<(), rustc_driver_impl[799d235ef8173497]::run_compiler::{closure#0}>::{closure#1}
  19:     0x7f6e93b096c7 - std[5bd9112d56c9e542]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8b029a4f81d57bf6]::util::run_in_thread_with_globals<rustc_interface[8b029a4f81d57bf6]::util::run_in_thread_pool_with_globals<rustc_interface[8b029a4f81d57bf6]::interface::run_compiler<(), rustc_driver_impl[799d235ef8173497]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  20:     0x7f6e93b093a8 - <<std[5bd9112d56c9e542]::thread::Builder>::spawn_unchecked_<rustc_interface[8b029a4f81d57bf6]::util::run_in_thread_with_globals<rustc_interface[8b029a4f81d57bf6]::util::run_in_thread_pool_with_globals<rustc_interface[8b029a4f81d57bf6]::interface::run_compiler<(), rustc_driver_impl[799d235ef8173497]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[16b3fef4fa94656]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:     0x7f6e93b0facd - std::sys::thread::unix::Thread::new::thread_start::h41545b42ecfc43e3
  22:     0x7f6e8d4969cb - <unknown>
  23:     0x7f6e8d51aa0c - <unknown>
  24:                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.92.0-nightly (8111a2d6d 2025-10-06) running on x86_64-unknown-linux-gnu

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

query stack during panic:
end of query stack
warning: 2 warnings emitted


@rustbot label +F-c_variadic

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-c_variadic`#![feature(c_variadic)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions