Skip to content

Commit 5676bd5

Browse files
committed
Break when there is a mismatch in the type count
When other errors are generated, there can be a mismatch between the amount of input types in MIR, and the amount in the function itself. Break from the comparative loop if this is the case to prevent out-of-bounds.
1 parent b8719c5 commit 5676bd5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/rustc_mir/src/borrow_check/type_check/input_output.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
7070

7171
// Equate expected input tys with those in the MIR.
7272
for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() {
73+
if argument_index + 1 >= body.local_decls.len() {
74+
self.tcx()
75+
.sess
76+
.delay_span_bug(body.span, "found more normalized_input_ty than local_decls");
77+
break;
78+
}
7379
// In MIR, argument N is stored in local N+1.
7480
let local = Local::new(argument_index + 1);
7581

0 commit comments

Comments
 (0)