Skip to content

Commit 755252b

Browse files
committed
Show the effects of weird code commented out
1 parent bd176ee commit 755252b

File tree

6 files changed

+35
-47
lines changed

6 files changed

+35
-47
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1135,20 +1135,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11351135
}
11361136
}
11371137

1138-
// Incorporate the argument changes in the removal suggestion.
1139-
let mut prev = -1;
1140-
for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
1141-
if let Some(provided_idx) = provided_idx {
1142-
prev = provided_idx.index() as i64;
1143-
}
1144-
let idx = ProvidedIdx::from_usize((prev + 1) as usize);
1145-
if let None = provided_idx
1146-
&& let Some((_, arg_span)) = provided_arg_tys.get(idx)
1147-
{
1148-
let (_, expected_ty) = formal_and_expected_inputs[expected_idx];
1149-
suggestions.push((*arg_span, ty_to_snippet(expected_ty, expected_idx)));
1150-
}
1151-
}
1138+
// // Incorporate the argument changes in the removal suggestion.
1139+
// let mut prev = -1;
1140+
// for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
1141+
// if let Some(provided_idx) = provided_idx {
1142+
// prev = provided_idx.index() as i64;
1143+
// }
1144+
// let idx = ProvidedIdx::from_usize((prev + 1) as usize);
1145+
// if let None = provided_idx
1146+
// && let Some((_, arg_span)) = provided_arg_tys.get(idx)
1147+
// {
1148+
// let (_, expected_ty) = formal_and_expected_inputs[expected_idx];
1149+
// suggestions.push((*arg_span, ty_to_snippet(expected_ty, expected_idx)));
1150+
// }
1151+
// }
11521152

11531153
// If we have less than 5 things to say, it would be useful to call out exactly what's wrong
11541154
if labels.len() <= 5 {

tests/ui/argument-suggestions/issue-97484.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | foo(&&A, B, C, D, &E, F, G);
2020
help: remove the extra arguments
2121
|
2222
LL - foo(&&A, B, C, D, E, F, G);
23-
LL + foo(&&A, D, /* &E */, G);
23+
LL + foo(&&A, D, E, G);
2424
|
2525

2626
error: aborting due to previous error

tests/ui/argument-suggestions/mixed_cases.stderr

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
22
--> $DIR/mixed_cases.rs:10:3
33
|
44
LL | two_args(1, "", X {});
5-
| ^^^^^^^^ -- ---- unexpected argument of type `X`
6-
| |
5+
| ^^^^^^^^ --------
6+
| | | |
7+
| | | unexpected argument of type `X`
8+
| | help: remove the extra argument
79
| expected `f32`, found `&str`
810
|
911
note: function defined here
1012
--> $DIR/mixed_cases.rs:5:4
1113
|
1214
LL | fn two_args(_a: i32, _b: f32) {}
1315
| ^^^^^^^^ ------- -------
14-
help: remove the extra argument
15-
|
16-
LL - two_args(1, "", X {});
17-
LL + two_args(1, /* f32 */);
18-
|
1916

2017
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
2118
--> $DIR/mixed_cases.rs:11:3

tests/ui/mismatched_types/overloaded-calls-bad.stderr

+4-7
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,17 @@ error[E0057]: this function takes 1 argument but 2 arguments were supplied
3232
--> $DIR/overloaded-calls-bad.rs:37:15
3333
|
3434
LL | let ans = s("burma", "shave");
35-
| ^ ------- ------- unexpected argument of type `&'static str`
36-
| |
35+
| ^ ----------------
36+
| | | |
37+
| | | unexpected argument of type `&'static str`
38+
| | help: remove the extra argument
3739
| expected `isize`, found `&str`
3840
|
3941
note: implementation defined here
4042
--> $DIR/overloaded-calls-bad.rs:10:1
4143
|
4244
LL | impl FnMut<(isize,)> for S {
4345
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
44-
help: remove the extra argument
45-
|
46-
LL - let ans = s("burma", "shave");
47-
LL + let ans = s(/* isize */);
48-
|
4946

5047
error[E0308]: mismatched types
5148
--> $DIR/overloaded-calls-bad.rs:40:7

tests/ui/suggestions/args-instead-of-tuple-errors.stderr

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
22
--> $DIR/args-instead-of-tuple-errors.rs:6:34
33
|
44
LL | let _: Option<(i32, bool)> = Some(1, 2);
5-
| ^^^^ - unexpected argument of type `{integer}`
5+
| ^^^^ ---
6+
| | |
7+
| | unexpected argument of type `{integer}`
8+
| help: remove the extra argument
69
|
710
note: expected `(i32, bool)`, found integer
811
--> $DIR/args-instead-of-tuple-errors.rs:6:39
@@ -20,17 +23,15 @@ LL | let _: Option<(i32, bool)> = Some(1, 2);
2023
| this argument influences the type of `Some`
2124
note: tuple variant defined here
2225
--> $SRC_DIR/core/src/option.rs:LL:COL
23-
help: remove the extra argument
24-
|
25-
LL - let _: Option<(i32, bool)> = Some(1, 2);
26-
LL + let _: Option<(i32, bool)> = Some(/* (i32, bool) */);
27-
|
2826

2927
error[E0061]: this function takes 1 argument but 2 arguments were supplied
3028
--> $DIR/args-instead-of-tuple-errors.rs:8:5
3129
|
3230
LL | int_bool(1, 2);
33-
| ^^^^^^^^ - unexpected argument of type `{integer}`
31+
| ^^^^^^^^ ---
32+
| | |
33+
| | unexpected argument of type `{integer}`
34+
| help: remove the extra argument
3435
|
3536
note: expected `(i32, bool)`, found integer
3637
--> $DIR/args-instead-of-tuple-errors.rs:8:14
@@ -44,11 +45,6 @@ note: function defined here
4445
|
4546
LL | fn int_bool(_: (i32, bool)) {
4647
| ^^^^^^^^ --------------
47-
help: remove the extra argument
48-
|
49-
LL - int_bool(1, 2);
50-
LL + int_bool(/* (i32, bool) */);
51-
|
5248

5349
error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied
5450
--> $DIR/args-instead-of-tuple-errors.rs:11:28

tests/ui/tuple/wrong_argument_ice-3.stderr

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0061]: this method takes 1 argument but 2 arguments were supplied
22
--> $DIR/wrong_argument_ice-3.rs:9:16
33
|
44
LL | groups.push(new_group, vec![process]);
5-
| ^^^^ ------------- unexpected argument of type `Vec<&Process>`
5+
| ^^^^ ---------------
6+
| | |
7+
| | unexpected argument of type `Vec<&Process>`
8+
| help: remove the extra argument
69
|
710
note: expected `(Vec<String>, Vec<Process>)`, found `Vec<String>`
811
--> $DIR/wrong_argument_ice-3.rs:9:21
@@ -13,11 +16,6 @@ LL | groups.push(new_group, vec![process]);
1316
found struct `Vec<String>`
1417
note: associated function defined here
1518
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
16-
help: remove the extra argument
17-
|
18-
LL - groups.push(new_group, vec![process]);
19-
LL + groups.push(/* (Vec<String>, Vec<Process>) */);
20-
|
2119

2220
error: aborting due to previous error
2321

0 commit comments

Comments
 (0)