Skip to content

Commit

Permalink
Show the effects of weird code commented out
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Feb 14, 2023
1 parent bd176ee commit 755252b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 47 deletions.
28 changes: 14 additions & 14 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,20 +1135,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

// Incorporate the argument changes in the removal suggestion.
let mut prev = -1;
for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
if let Some(provided_idx) = provided_idx {
prev = provided_idx.index() as i64;
}
let idx = ProvidedIdx::from_usize((prev + 1) as usize);
if let None = provided_idx
&& let Some((_, arg_span)) = provided_arg_tys.get(idx)
{
let (_, expected_ty) = formal_and_expected_inputs[expected_idx];
suggestions.push((*arg_span, ty_to_snippet(expected_ty, expected_idx)));
}
}
// // Incorporate the argument changes in the removal suggestion.
// let mut prev = -1;
// for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
// if let Some(provided_idx) = provided_idx {
// prev = provided_idx.index() as i64;
// }
// let idx = ProvidedIdx::from_usize((prev + 1) as usize);
// if let None = provided_idx
// && let Some((_, arg_span)) = provided_arg_tys.get(idx)
// {
// let (_, expected_ty) = formal_and_expected_inputs[expected_idx];
// suggestions.push((*arg_span, ty_to_snippet(expected_ty, expected_idx)));
// }
// }

// If we have less than 5 things to say, it would be useful to call out exactly what's wrong
if labels.len() <= 5 {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/argument-suggestions/issue-97484.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LL | foo(&&A, B, C, D, &E, F, G);
help: remove the extra arguments
|
LL - foo(&&A, B, C, D, E, F, G);
LL + foo(&&A, D, /* &E */, G);
LL + foo(&&A, D, E, G);
|

error: aborting due to previous error
Expand Down
11 changes: 4 additions & 7 deletions tests/ui/argument-suggestions/mixed_cases.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/mixed_cases.rs:10:3
|
LL | two_args(1, "", X {});
| ^^^^^^^^ -- ---- unexpected argument of type `X`
| |
| ^^^^^^^^ --------
| | | |
| | | unexpected argument of type `X`
| | help: remove the extra argument
| expected `f32`, found `&str`
|
note: function defined here
--> $DIR/mixed_cases.rs:5:4
|
LL | fn two_args(_a: i32, _b: f32) {}
| ^^^^^^^^ ------- -------
help: remove the extra argument
|
LL - two_args(1, "", X {});
LL + two_args(1, /* f32 */);
|

error[E0061]: this function takes 3 arguments but 4 arguments were supplied
--> $DIR/mixed_cases.rs:11:3
Expand Down
11 changes: 4 additions & 7 deletions tests/ui/mismatched_types/overloaded-calls-bad.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ error[E0057]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/overloaded-calls-bad.rs:37:15
|
LL | let ans = s("burma", "shave");
| ^ ------- ------- unexpected argument of type `&'static str`
| |
| ^ ----------------
| | | |
| | | unexpected argument of type `&'static str`
| | help: remove the extra argument
| expected `isize`, found `&str`
|
note: implementation defined here
--> $DIR/overloaded-calls-bad.rs:10:1
|
LL | impl FnMut<(isize,)> for S {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: remove the extra argument
|
LL - let ans = s("burma", "shave");
LL + let ans = s(/* isize */);
|

error[E0308]: mismatched types
--> $DIR/overloaded-calls-bad.rs:40:7
Expand Down
20 changes: 8 additions & 12 deletions tests/ui/suggestions/args-instead-of-tuple-errors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple-errors.rs:6:34
|
LL | let _: Option<(i32, bool)> = Some(1, 2);
| ^^^^ - unexpected argument of type `{integer}`
| ^^^^ ---
| | |
| | unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: expected `(i32, bool)`, found integer
--> $DIR/args-instead-of-tuple-errors.rs:6:39
Expand All @@ -20,17 +23,15 @@ LL | let _: Option<(i32, bool)> = Some(1, 2);
| this argument influences the type of `Some`
note: tuple variant defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
help: remove the extra argument
|
LL - let _: Option<(i32, bool)> = Some(1, 2);
LL + let _: Option<(i32, bool)> = Some(/* (i32, bool) */);
|

error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/args-instead-of-tuple-errors.rs:8:5
|
LL | int_bool(1, 2);
| ^^^^^^^^ - unexpected argument of type `{integer}`
| ^^^^^^^^ ---
| | |
| | unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: expected `(i32, bool)`, found integer
--> $DIR/args-instead-of-tuple-errors.rs:8:14
Expand All @@ -44,11 +45,6 @@ note: function defined here
|
LL | fn int_bool(_: (i32, bool)) {
| ^^^^^^^^ --------------
help: remove the extra argument
|
LL - int_bool(1, 2);
LL + int_bool(/* (i32, bool) */);
|

error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied
--> $DIR/args-instead-of-tuple-errors.rs:11:28
Expand Down
10 changes: 4 additions & 6 deletions tests/ui/tuple/wrong_argument_ice-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ error[E0061]: this method takes 1 argument but 2 arguments were supplied
--> $DIR/wrong_argument_ice-3.rs:9:16
|
LL | groups.push(new_group, vec![process]);
| ^^^^ ------------- unexpected argument of type `Vec<&Process>`
| ^^^^ ---------------
| | |
| | unexpected argument of type `Vec<&Process>`
| help: remove the extra argument
|
note: expected `(Vec<String>, Vec<Process>)`, found `Vec<String>`
--> $DIR/wrong_argument_ice-3.rs:9:21
Expand All @@ -13,11 +16,6 @@ LL | groups.push(new_group, vec![process]);
found struct `Vec<String>`
note: associated function defined here
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: remove the extra argument
|
LL - groups.push(new_group, vec![process]);
LL + groups.push(/* (Vec<String>, Vec<Process>) */);
|

error: aborting due to previous error

Expand Down

0 comments on commit 755252b

Please sign in to comment.