mirror of https://github.com/rust-lang/rust.git
Make each idx is used once
This commit is contained in:
parent
bbfbecd59f
commit
80e4285531
|
@ -1156,18 +1156,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// ```
|
// ```
|
||||||
// which includes the replacement of the first two `()` for the correct type, and the
|
// which includes the replacement of the first two `()` for the correct type, and the
|
||||||
// removal of the last `()`.
|
// removal of the last `()`.
|
||||||
let mut idx = -1;
|
let mut prev = -1;
|
||||||
for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
|
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
|
// 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.
|
// index position where it *should have been*, which is *after* the previous one.
|
||||||
idx = match provided_idx {
|
if let Some(provided_idx) = provided_idx {
|
||||||
Some(provided_idx) => provided_idx.index() as i64 + 1,
|
prev = provided_idx.index() as i64;
|
||||||
None => idx + 1,
|
continue;
|
||||||
};
|
}
|
||||||
let idx = ProvidedIdx::from_usize(idx as usize);
|
let idx = ProvidedIdx::from_usize((prev + 1) as usize);
|
||||||
if let None = provided_idx
|
if let Some((_, arg_span)) = provided_arg_tys.get(idx) {
|
||||||
&& let Some((_, arg_span)) = provided_arg_tys.get(idx)
|
prev += 1;
|
||||||
{
|
|
||||||
// There is a type that was *not* found anywhere, so it isn't a move, but a
|
// There is a type that was *not* found anywhere, so it isn't a move, but a
|
||||||
// replacement and we look at what type it should have been. This will allow us
|
// replacement and we look at what type it should have been. This will allow us
|
||||||
// To suggest a multipart suggestion when encountering `foo(1, "")` where the def
|
// To suggest a multipart suggestion when encountering `foo(1, "")` where the def
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0412]: cannot find type `C` in this scope
|
error[E0412]: cannot find type `C` in this scope
|
||||||
--> $DIR/109831.rs:4:24
|
--> $DIR/issue-109831.rs:4:24
|
||||||
|
|
|
|
||||||
LL | struct A;
|
LL | struct A;
|
||||||
| --------- similarly named struct `A` defined here
|
| --------- similarly named struct `A` defined here
|
||||||
|
@ -17,7 +17,7 @@ LL | fn f<C>(b1: B, b2: B, a2: C) {}
|
||||||
| +++
|
| +++
|
||||||
|
|
||||||
error[E0425]: cannot find value `C` in this scope
|
error[E0425]: cannot find value `C` in this scope
|
||||||
--> $DIR/109831.rs:7:16
|
--> $DIR/issue-109831.rs:7:16
|
||||||
|
|
|
|
||||||
LL | struct A;
|
LL | struct A;
|
||||||
| --------- similarly named unit struct `A` defined here
|
| --------- similarly named unit struct `A` defined here
|
||||||
|
@ -26,7 +26,7 @@ LL | f(A, A, B, C);
|
||||||
| ^ help: a unit struct with a similar name exists: `A`
|
| ^ help: a unit struct with a similar name exists: `A`
|
||||||
|
|
||||||
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
|
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
|
||||||
--> $DIR/109831.rs:7:5
|
--> $DIR/issue-109831.rs:7:5
|
||||||
|
|
|
|
||||||
LL | f(A, A, B, C);
|
LL | f(A, A, B, C);
|
||||||
| ^ - - - unexpected argument
|
| ^ - - - unexpected argument
|
||||||
|
@ -35,7 +35,7 @@ LL | f(A, A, B, C);
|
||||||
| expected `B`, found `A`
|
| expected `B`, found `A`
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> $DIR/109831.rs:4:4
|
--> $DIR/issue-109831.rs:4:4
|
||||||
|
|
|
|
||||||
LL | fn f(b1: B, b2: B, a2: C) {}
|
LL | fn f(b1: B, b2: B, a2: C) {}
|
||||||
| ^ ----- ----- -----
|
| ^ ----- ----- -----
|
Loading…
Reference in New Issue