about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMu42 <mu001999@outlook.com>2023-04-02 10:48:01 +0800
committerMu42 <mu001999@outlook.com>2023-04-02 10:48:01 +0800
commitbbfbecd59ff99b51d1ccf7764641ef32209b9dad (patch)
tree5df94f84945e70d7f4218e37d67eac8bd6ceb2c1 /compiler
parent0f6312f643aa1a8713e203a9ce2307f8b622b226 (diff)
downloadrust-bbfbecd59ff99b51d1ccf7764641ef32209b9dad.tar.gz
rust-bbfbecd59ff99b51d1ccf7764641ef32209b9dad.zip
Do not repeat idx
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 61338ac613a..32c603e4897 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -1156,14 +1156,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         // ```
         // which includes the replacement of the first two `()` for the correct type, and the
         // removal of the last `()`.
-        let mut prev = -1;
+        let mut idx = -1;
         for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
             // We want to point not at the *current* argument expression index, but rather at the
             // index position where it *should have been*, which is *after* the previous one.
-            if let Some(provided_idx) = provided_idx {
-                prev = provided_idx.index() as i64;
-            }
-            let idx = ProvidedIdx::from_usize((prev + 1) as usize);
+            idx = match provided_idx {
+                Some(provided_idx) => provided_idx.index() as i64 + 1,
+                None => idx + 1,
+            };
+            let idx = ProvidedIdx::from_usize(idx as usize);
             if let None = provided_idx
                 && let Some((_, arg_span)) = provided_arg_tys.get(idx)
             {