From 189305eda3d5be1d7dbc9002bfd9a0b27478c3ac Mon Sep 17 00:00:00 2001 From: Jacob Adam Date: Sun, 12 Apr 2026 23:21:13 +0100 Subject: [PATCH] Skip the closure signature annotation check for tainted bodies When a coroutine has too many parameters, `check_match` fails and `construct_error` builds a MIR body with only the coroutine's computed args (env + resume type). The user-provided signature, however, still reflects all the parameters the user wrote. `check_signature_annotation` then tries to `zip_eq` these two mismatched iterators, causing a panic. Checking `tainted_by_errors` and bailing early avoids this, since `construct_error` bodies cannot meaningfully be compared against user annotations. --- compiler/rustc_borrowck/src/type_check/input_output.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index 4e762b368496..39b3e525bc4c 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -32,6 +32,15 @@ pub(super) fn check_signature_annotation(&mut self) { return; } + // If the MIR body was constructed via `construct_error` (because an + // earlier pass like match checking failed), its args may not match + // the user-provided signature (e.g. a coroutine with too many + // parameters). Bail out as this can cause panic, + // see . + if self.body.tainted_by_errors.is_some() { + return; + } + let user_provided_poly_sig = self.tcx().closure_user_provided_sig(mir_def_id); // Instantiate the canonicalized variables from user-provided signature