Rollup merge of #145662 - GrigorenkoPV:x86-interrupt, r=compiler-errors

Enforce correct number of arguments for `"x86-interrupt"` functions

Tracking issue: rust-lang/rust#40180

Partially fixes rust-lang/rust#132835

`````@rustbot````` label: +F-abi_x86_interrupt +A-LLVM +O-x86_64 +O-x86_32 +A-ABI
This commit is contained in:
Jacob Pratt
2025-08-21 01:12:24 -04:00
committed by GitHub
23 changed files with 197 additions and 123 deletions

View File

@@ -405,6 +405,17 @@ impl<'a> AstValidator<'a> {
if let InterruptKind::X86 = interrupt_kind {
// "x86-interrupt" is special because it does have arguments.
// FIXME(workingjubilee): properly lint on acceptable input types.
let inputs = &sig.decl.inputs;
let param_count = inputs.len();
if !matches!(param_count, 1 | 2) {
let mut spans: Vec<Span> =
inputs.iter().map(|arg| arg.span).collect();
if spans.is_empty() {
spans = vec![sig.span];
}
self.dcx().emit_err(errors::AbiX86Interrupt { spans, param_count });
}
if let FnRetTy::Ty(ref ret_ty) = sig.decl.output
&& match &ret_ty.kind {
TyKind::Never => false,