Repository navigation
Description
There is a problem with the assertion at
| assert!(!self.c_variadic || matches!(self.conv, CanonAbi::C)); |
If any tool using rustc_public calls rustc_public::mir::mono::Instance::fn_abi() to know "what's this function's calling-convention layout?" there is a check that says "if the function is variadic, the convention must be C," which is wrong. extern "sysv64" variadics are also legal Rust. The stable enum has a variant for this convention already (CallConvention::X86_64SysV). Here is a way to reproduce the issue below.
Environment
rustc 1.100.0-nightly (6bb1652a0 2026-09-22)(nightly-2026-09-23)rustc-devcomponent installed- x86-64 host. On aarch64 rustc rejects
extern "sysv64"withE0570, so the input does not build.
Files
fn_abi_ice.rs is the driver and it asks every function in the crate under compilation for its FnAbi.
#![feature(rustc_private)]
extern crate rustc_driver;
extern crate rustc_interface;
extern crate rustc_middle;
extern crate rustc_public;
extern crate rustc_session;
use rustc_public::CrateDef;
use rustc_public::mir::mono::Instance;
use rustc_public::run;
use std::convert::TryInto;
use std::ops::ControlFlow;
fn ask_every_function_for_its_abi() -> ControlFlow<()> {
for item in rustc_public::all_local_items() {
let Ok(instance) = TryInto::<Instance>::try_into(item) else { continue };
println!("asking for the ABI of `{}`", instance.name());
let _ = instance.fn_abi();
}
ControlFlow::Continue(())
}
fn main() {
let args: Vec<String> = std::env::args().collect();
let _ = run!(&args, ask_every_function_for_its_abi);
}repro.rs is the input.
#[unsafe(naked)]
pub unsafe extern "sysv64" fn defined(_: u32, _: ...) -> u32 {
core::arch::naked_asm!("")
}
unsafe extern "sysv64" {
pub fn declared(_: u32, _: ...) -> u32;
}control.rs is the same two shapes with the C convention + a plain function.
pub unsafe extern "C" fn defined_c(a: u32, _: ...) -> u32 { a }
unsafe extern "C" {
pub fn declared_c(_: u32, _: ...) -> u32;
}
pub fn plain(a: u32) -> u32 { a }Steps
$ rustc +nightly-2026-09-23 fn_abi_ice.rs -o fn_abi_ice
$ LD_LIBRARY_PATH=$(rustc +nightly-2026-09-23 --print target-libdir)/../lib \
./fn_abi_ice repro.rs --crate-type=lib
asking for the ABI of `repro::defined`
thread 'rustc' (13085) panicked at compiler/rustc_public/src/unstable/convert/stable/abi.rs:92:9:
assertion failed: !self.c_variadic || matches!(self.conv, CanonAbi::C)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
101$ LD_LIBRARY_PATH=$(rustc +nightly-2026-09-23 --print target-libdir)/../lib \
./fn_abi_ice control.rs --crate-type=lib
asking for the ABI of `control::defined_c`
asking for the ABI of `control::plain`
$ echo $?
0Expected: fn_abi() returns, or returns an Err, for repro.rs as it does for control.rs.
Actual: the assertion aborts compilation.
thread 'rustc' panicked at compiler/rustc_public/src/unstable/convert/stable/abi.rs:92:9:
assertion failed: !self.c_variadic || matches!(self.conv, CanonAbi::C)
Activity
theemathas commentedon Sep 24, 2026
Please note the LLM Policy.
This issue is difficult to read and comprehend, as is typical of LLM writing.
feliperodri commentedon Sep 24, 2026
I'll re-open with a better description.
feliperodri commentedon Sep 26, 2026
I re-opened the issue with a new description. @theemathas, is it more readable now?
Report variadic functions with a non-C ABI as unsupported (model-chec…
Rollup merge of rust-lang#165388 - lapla-cogito:issue_163233, r=makai410
Rollup merge of rust-lang#165388 - lapla-cogito:issue_163233, r=makai410
Rollup merge of rust-lang#165388 - lapla-cogito:issue_163233, r=makai410
Unrolled build for #165388 in rollup 165579
Rollup merge of #165388 - lapla-cogito:issue_163233, r=makai410