rust/tests/pretty/hir-fn-variadic.rs
Nicholas Nethercote f8edc831ca Pretty-print PatKind::Missing as _.
Printing "no pattern" as `_` isn't ideal, but better than crashing, and
HIR pretty-printing already has plenty of imperfections. The added `f2`
and `f6` examples are ones that triggered the crash.

Note that some of the added examples are printed badly, e.g.
`fn(, ...)`. The next commit will fix those.

Fixes #139633.
2025-04-15 10:40:58 +10:00

29 lines
709 B
Rust

//@ pretty-compare-only
//@ pretty-mode:hir
//@ pp-exact:hir-fn-variadic.pp
#![feature(c_variadic)]
extern "C" {
pub fn foo(x: i32, va1: ...);
}
pub unsafe extern "C" fn bar(_: i32, mut va2: ...) -> usize {
va2.arg::<usize>()
}
fn main() {
fn g1(_: extern "C" fn(_: u8, va: ...)) {}
fn g2(_: extern "C" fn(_: u8, ...)) {}
fn g3(_: extern "C" fn(u8, va: ...)) {}
fn g4(_: extern "C" fn(u8, ...)) {}
fn g5(_: extern "C" fn(va: ...)) {}
fn g6(_: extern "C" fn(...)) {}
_ = { unsafe extern "C" fn f1(_: u8, va: ...) {} };
_ = { unsafe extern "C" fn f2(_: u8, ...) {} };
_ = { unsafe extern "C" fn f5(va: ...) {} };
_ = { unsafe extern "C" fn f6(...) {} };
}