Skip to content

Commit 4718cb4

Browse files
committed
When displaying a parameter mismatch error, only highlight the mismatched parameters when showing the definition.
1 parent 820bfff commit 4718cb4

28 files changed

+246
-312
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+155-161
Large diffs are not rendered by default.

tests/ui/argument-suggestions/basic.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ note: function defined here
5757
--> $DIR/basic.rs:16:4
5858
|
5959
LL | fn swapped(_i: u32, _s: &str) {}
60-
| ^^^^^^^ ------- --------
60+
| ^^^^^^^
6161
help: swap these arguments
6262
|
6363
LL | swapped(1, "");
@@ -76,7 +76,7 @@ note: function defined here
7676
--> $DIR/basic.rs:17:4
7777
|
7878
LL | fn permuted(_x: X, _y: Y, _z: Z) {}
79-
| ^^^^^^^^ ----- ----- -----
79+
| ^^^^^^^^
8080
help: reorder these arguments
8181
|
8282
LL | permuted(X {}, Y {}, Z {});

tests/ui/argument-suggestions/complex.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: function defined here
88
--> $DIR/complex.rs:11:4
99
|
1010
LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {}
11-
| ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- -----
11+
| ^^^^^^^ ------- -----
1212
help: did you mean
1313
|
1414
LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {});

tests/ui/argument-suggestions/extra_arguments.stderr

+17-17
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ note: function defined here
4444
--> $DIR/extra_arguments.rs:2:4
4545
|
4646
LL | fn one_arg<T>(_a: T) {}
47-
| ^^^^^^^ -----
47+
| ^^^^^^^
4848
help: remove the extra argument
4949
|
5050
LL - one_arg(1, 1);
@@ -61,7 +61,7 @@ note: function defined here
6161
--> $DIR/extra_arguments.rs:2:4
6262
|
6363
LL | fn one_arg<T>(_a: T) {}
64-
| ^^^^^^^ -----
64+
| ^^^^^^^
6565
help: remove the extra argument
6666
|
6767
LL - one_arg(1, "");
@@ -80,7 +80,7 @@ note: function defined here
8080
--> $DIR/extra_arguments.rs:2:4
8181
|
8282
LL | fn one_arg<T>(_a: T) {}
83-
| ^^^^^^^ -----
83+
| ^^^^^^^
8484
help: remove the extra arguments
8585
|
8686
LL - one_arg(1, "", 1.0);
@@ -97,7 +97,7 @@ note: function defined here
9797
--> $DIR/extra_arguments.rs:3:4
9898
|
9999
LL | fn two_arg_same(_a: i32, _b: i32) {}
100-
| ^^^^^^^^^^^^ ------- -------
100+
| ^^^^^^^^^^^^
101101
help: remove the extra argument
102102
|
103103
LL - two_arg_same(1, 1, 1);
@@ -114,7 +114,7 @@ note: function defined here
114114
--> $DIR/extra_arguments.rs:3:4
115115
|
116116
LL | fn two_arg_same(_a: i32, _b: i32) {}
117-
| ^^^^^^^^^^^^ ------- -------
117+
| ^^^^^^^^^^^^
118118
help: remove the extra argument
119119
|
120120
LL - two_arg_same(1, 1, 1.0);
@@ -131,7 +131,7 @@ note: function defined here
131131
--> $DIR/extra_arguments.rs:4:4
132132
|
133133
LL | fn two_arg_diff(_a: i32, _b: &str) {}
134-
| ^^^^^^^^^^^^ ------- --------
134+
| ^^^^^^^^^^^^
135135
help: remove the extra argument
136136
|
137137
LL - two_arg_diff(1, 1, "");
@@ -148,7 +148,7 @@ note: function defined here
148148
--> $DIR/extra_arguments.rs:4:4
149149
|
150150
LL | fn two_arg_diff(_a: i32, _b: &str) {}
151-
| ^^^^^^^^^^^^ ------- --------
151+
| ^^^^^^^^^^^^
152152
help: remove the extra argument
153153
|
154154
LL - two_arg_diff(1, "", "");
@@ -167,7 +167,7 @@ note: function defined here
167167
--> $DIR/extra_arguments.rs:4:4
168168
|
169169
LL | fn two_arg_diff(_a: i32, _b: &str) {}
170-
| ^^^^^^^^^^^^ ------- --------
170+
| ^^^^^^^^^^^^
171171
help: remove the extra arguments
172172
|
173173
LL - two_arg_diff(1, 1, "", "");
@@ -186,7 +186,7 @@ note: function defined here
186186
--> $DIR/extra_arguments.rs:4:4
187187
|
188188
LL | fn two_arg_diff(_a: i32, _b: &str) {}
189-
| ^^^^^^^^^^^^ ------- --------
189+
| ^^^^^^^^^^^^
190190
help: remove the extra arguments
191191
|
192192
LL - two_arg_diff(1, "", 1, "");
@@ -203,7 +203,7 @@ note: function defined here
203203
--> $DIR/extra_arguments.rs:3:4
204204
|
205205
LL | fn two_arg_same(_a: i32, _b: i32) {}
206-
| ^^^^^^^^^^^^ ------- -------
206+
| ^^^^^^^^^^^^
207207
help: remove the extra argument
208208
|
209209
LL - two_arg_same(1, 1, "");
@@ -220,7 +220,7 @@ note: function defined here
220220
--> $DIR/extra_arguments.rs:4:4
221221
|
222222
LL | fn two_arg_diff(_a: i32, _b: &str) {}
223-
| ^^^^^^^^^^^^ ------- --------
223+
| ^^^^^^^^^^^^
224224
help: remove the extra argument
225225
|
226226
LL - two_arg_diff(1, 1, "");
@@ -240,7 +240,7 @@ note: function defined here
240240
--> $DIR/extra_arguments.rs:3:4
241241
|
242242
LL | fn two_arg_same(_a: i32, _b: i32) {}
243-
| ^^^^^^^^^^^^ ------- -------
243+
| ^^^^^^^^^^^^
244244
help: remove the extra argument
245245
|
246246
LL - 1,
@@ -261,7 +261,7 @@ note: function defined here
261261
--> $DIR/extra_arguments.rs:4:4
262262
|
263263
LL | fn two_arg_diff(_a: i32, _b: &str) {}
264-
| ^^^^^^^^^^^^ ------- --------
264+
| ^^^^^^^^^^^^
265265
help: remove the extra argument
266266
|
267267
LL - 1,
@@ -335,7 +335,7 @@ note: function defined here
335335
--> $DIR/extra_arguments.rs:2:4
336336
|
337337
LL | fn one_arg<T>(_a: T) {}
338-
| ^^^^^^^ -----
338+
| ^^^^^^^
339339
help: remove the extra argument
340340
|
341341
LL - one_arg(1, panic!());
@@ -352,7 +352,7 @@ note: function defined here
352352
--> $DIR/extra_arguments.rs:2:4
353353
|
354354
LL | fn one_arg<T>(_a: T) {}
355-
| ^^^^^^^ -----
355+
| ^^^^^^^
356356
help: remove the extra argument
357357
|
358358
LL - one_arg(panic!(), 1);
@@ -369,7 +369,7 @@ note: function defined here
369369
--> $DIR/extra_arguments.rs:2:4
370370
|
371371
LL | fn one_arg<T>(_a: T) {}
372-
| ^^^^^^^ -----
372+
| ^^^^^^^
373373
help: remove the extra argument
374374
|
375375
LL - one_arg(stringify!($e), 1);
@@ -386,7 +386,7 @@ note: function defined here
386386
--> $DIR/extra_arguments.rs:2:4
387387
|
388388
LL | fn one_arg<T>(_a: T) {}
389-
| ^^^^^^^ -----
389+
| ^^^^^^^
390390
help: remove the extra argument
391391
|
392392
LL - one_arg(for _ in 1.. {}, 1);

tests/ui/argument-suggestions/invalid_arguments.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ note: function defined here
150150
--> $DIR/invalid_arguments.rs:8:4
151151
|
152152
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
153-
| ^^^^^^^^^^^^^^ ------- ------- --------
153+
| ^^^^^^^^^^^^^^ ------- -------
154154

155155
error[E0308]: arguments to this function are incorrect
156156
--> $DIR/invalid_arguments.rs:29:3
@@ -164,7 +164,7 @@ note: function defined here
164164
--> $DIR/invalid_arguments.rs:8:4
165165
|
166166
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
167-
| ^^^^^^^^^^^^^^ ------- ------- --------
167+
| ^^^^^^^^^^^^^^ ------- --------
168168

169169
error[E0308]: arguments to this function are incorrect
170170
--> $DIR/invalid_arguments.rs:30:3
@@ -178,7 +178,7 @@ note: function defined here
178178
--> $DIR/invalid_arguments.rs:8:4
179179
|
180180
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
181-
| ^^^^^^^^^^^^^^ ------- ------- --------
181+
| ^^^^^^^^^^^^^^ ------- --------
182182

183183
error[E0308]: arguments to this function are incorrect
184184
--> $DIR/invalid_arguments.rs:32:3
@@ -249,7 +249,7 @@ note: function defined here
249249
--> $DIR/invalid_arguments.rs:9:4
250250
|
251251
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
252-
| ^^^^^^^^^^^^^^^^ ------- ------- --------
252+
| ^^^^^^^^^^^^^^^^ ------- -------
253253

254254
error[E0308]: arguments to this function are incorrect
255255
--> $DIR/invalid_arguments.rs:39:3
@@ -263,7 +263,7 @@ note: function defined here
263263
--> $DIR/invalid_arguments.rs:9:4
264264
|
265265
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
266-
| ^^^^^^^^^^^^^^^^ ------- ------- --------
266+
| ^^^^^^^^^^^^^^^^ ------- --------
267267

268268
error[E0308]: arguments to this function are incorrect
269269
--> $DIR/invalid_arguments.rs:40:3
@@ -277,7 +277,7 @@ note: function defined here
277277
--> $DIR/invalid_arguments.rs:9:4
278278
|
279279
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
280-
| ^^^^^^^^^^^^^^^^ ------- ------- --------
280+
| ^^^^^^^^^^^^^^^^ ------- --------
281281

282282
error[E0308]: arguments to this function are incorrect
283283
--> $DIR/invalid_arguments.rs:42:3

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: function defined here
1111
--> $DIR/issue-100478.rs:30:4
1212
|
1313
LL | fn three_diff(_a: T1, _b: T2, _c: T3) {}
14-
| ^^^^^^^^^^ ------ ------ ------
14+
| ^^^^^^^^^^ ------ ------
1515
help: provide the arguments
1616
|
1717
LL | three_diff(/* T1 */, T2::new(0), /* T3 */);
@@ -31,7 +31,7 @@ note: function defined here
3131
--> $DIR/issue-100478.rs:31:4
3232
|
3333
LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
34-
| ^^^^^^^^^^^^ ------ ------ ------ ------
34+
| ^^^^^^^^^^^^
3535
help: did you mean
3636
|
3737
LL | four_shuffle(T1::default(), T2::default(), T3::default(), T4::default());
@@ -50,7 +50,7 @@ note: function defined here
5050
--> $DIR/issue-100478.rs:31:4
5151
|
5252
LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
53-
| ^^^^^^^^^^^^ ------ ------ ------ ------
53+
| ^^^^^^^^^^^^ ------
5454
help: swap these arguments
5555
|
5656
LL | four_shuffle(T1::default(), T2::default(), T3::default(), /* T4 */);
@@ -69,7 +69,7 @@ note: function defined here
6969
--> $DIR/issue-100478.rs:29:4
7070
|
7171
LL | fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {}
72-
| ^^^ ------ ----------- ------ ----------- ------ ------ ------ -----------
72+
| ^^^ -----------
7373
help: provide the argument
7474
|
7575
LL | foo(p1, /* Arc<T2> */, p3, p4, p5, p6, p7, p8);

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

+2-54
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ note: function defined here
1313
|
1414
LL | fn f(
1515
| ^
16-
LL | a1: A,
17-
| -----
18-
LL | a2: A,
19-
| -----
20-
LL | b1: B,
21-
| -----
22-
LL | b2: B,
23-
| -----
24-
LL | c1: C,
25-
| -----
26-
LL | c2: C,
27-
| -----
2816
help: did you mean
2917
|
3018
LL | f(A, A, B, B, C, C);
@@ -41,18 +29,6 @@ note: function defined here
4129
|
4230
LL | fn f(
4331
| ^
44-
LL | a1: A,
45-
| -----
46-
LL | a2: A,
47-
| -----
48-
LL | b1: B,
49-
| -----
50-
LL | b2: B,
51-
| -----
52-
LL | c1: C,
53-
| -----
54-
LL | c2: C,
55-
| -----
5632
help: did you mean
5733
|
5834
LL | f(A, A, B, B, C, C);
@@ -72,14 +48,7 @@ note: function defined here
7248
|
7349
LL | fn f(
7450
| ^
75-
LL | a1: A,
76-
| -----
77-
LL | a2: A,
78-
| -----
79-
LL | b1: B,
80-
| -----
81-
LL | b2: B,
82-
| -----
51+
...
8352
LL | c1: C,
8453
| -----
8554
LL | c2: C,
@@ -104,18 +73,6 @@ note: function defined here
10473
|
10574
LL | fn f(
10675
| ^
107-
LL | a1: A,
108-
| -----
109-
LL | a2: A,
110-
| -----
111-
LL | b1: B,
112-
| -----
113-
LL | b2: B,
114-
| -----
115-
LL | c1: C,
116-
| -----
117-
LL | c2: C,
118-
| -----
11976
help: did you mean
12077
|
12178
LL | f(A, A, B, B, C, C);
@@ -137,18 +94,9 @@ note: function defined here
13794
|
13895
LL | fn f(
13996
| ^
140-
LL | a1: A,
141-
| -----
142-
LL | a2: A,
143-
| -----
97+
...
14498
LL | b1: B,
14599
| -----
146-
LL | b2: B,
147-
| -----
148-
LL | c1: C,
149-
| -----
150-
LL | c2: C,
151-
| -----
152100
help: did you mean
153101
|
154102
LL | f(A, A, /* B */, B, C, C);

0 commit comments

Comments
 (0)