mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
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.
This commit is contained in:
@@ -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 <https://github.com/rust-lang/rust/issues/139570>.
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user