Skip to content

Commit 0c7dc80

Browse files
committed
Fix existing tests
1 parent 1411163 commit 0c7dc80

File tree

13 files changed

+44
-101
lines changed

13 files changed

+44
-101
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22472247
let mut unmatched_params_map: Vec<(usize, &hir::Param<'_>)> = Vec::new();
22482248

22492249
for (idx, (param, generic)) in
2250-
params.iter().zip_eq(param_generics.iter()).enumerate()
2250+
params.iter().zip_eq(param_generics.iter()).enumerate().filter(
2251+
|(idx, (_, _))| {
2252+
expected_idx.map_or(true, |expected_idx| expected_idx == *idx)
2253+
},
2254+
)
22512255
{
22522256
if matched_inputs[idx.into()].is_none() {
22532257
spans.push_span_label(param.span, "");
@@ -2272,6 +2276,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22722276
}
22732277

22742278
if found_unmatched_generic_params.is_empty() {
2279+
spans.push_span_label(param.span, "");
22752280
continue;
22762281
}
22772282

tests/ui/argument-suggestions/extra_arguments.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ note: function defined here
4545
--> $DIR/extra_arguments.rs:2:4
4646
|
4747
LL | fn one_arg<T>(_a: T) {}
48-
| ^^^^^^^
48+
| ^^^^^^^ -----
4949

5050
error[E0061]: this function takes 1 argument but 2 arguments were supplied
5151
--> $DIR/extra_arguments.rs:23:3
@@ -60,7 +60,7 @@ note: function defined here
6060
--> $DIR/extra_arguments.rs:2:4
6161
|
6262
LL | fn one_arg<T>(_a: T) {}
63-
| ^^^^^^^
63+
| ^^^^^^^ -----
6464

6565
error[E0061]: this function takes 1 argument but 3 arguments were supplied
6666
--> $DIR/extra_arguments.rs:24:3
@@ -74,7 +74,7 @@ note: function defined here
7474
--> $DIR/extra_arguments.rs:2:4
7575
|
7676
LL | fn one_arg<T>(_a: T) {}
77-
| ^^^^^^^
77+
| ^^^^^^^ -----
7878
help: remove the extra arguments
7979
|
8080
LL - one_arg(1, "", 1.0);
@@ -319,7 +319,7 @@ note: function defined here
319319
--> $DIR/extra_arguments.rs:2:4
320320
|
321321
LL | fn one_arg<T>(_a: T) {}
322-
| ^^^^^^^
322+
| ^^^^^^^ -----
323323

324324
error[E0061]: this function takes 1 argument but 2 arguments were supplied
325325
--> $DIR/extra_arguments.rs:54:3
@@ -334,7 +334,7 @@ note: function defined here
334334
--> $DIR/extra_arguments.rs:2:4
335335
|
336336
LL | fn one_arg<T>(_a: T) {}
337-
| ^^^^^^^
337+
| ^^^^^^^ -----
338338

339339
error[E0061]: this function takes 1 argument but 2 arguments were supplied
340340
--> $DIR/extra_arguments.rs:55:3
@@ -349,7 +349,7 @@ note: function defined here
349349
--> $DIR/extra_arguments.rs:2:4
350350
|
351351
LL | fn one_arg<T>(_a: T) {}
352-
| ^^^^^^^
352+
| ^^^^^^^ -----
353353

354354
error[E0061]: this function takes 1 argument but 2 arguments were supplied
355355
--> $DIR/extra_arguments.rs:60:3
@@ -364,7 +364,7 @@ note: function defined here
364364
--> $DIR/extra_arguments.rs:2:4
365365
|
366366
LL | fn one_arg<T>(_a: T) {}
367-
| ^^^^^^^
367+
| ^^^^^^^ -----
368368

369369
error: aborting due to 22 previous errors
370370

tests/ui/argument-suggestions/invalid_arguments.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ note: function defined here
2424
--> $DIR/invalid_arguments.rs:6:4
2525
|
2626
LL | fn two_arg_same(_a: i32, _b: i32) {}
27-
| ^^^^^^^^^^^^ ------- -------
27+
| ^^^^^^^^^^^^ -------
2828

2929
error[E0308]: mismatched types
3030
--> $DIR/invalid_arguments.rs:17:16
@@ -38,7 +38,7 @@ note: function defined here
3838
--> $DIR/invalid_arguments.rs:6:4
3939
|
4040
LL | fn two_arg_same(_a: i32, _b: i32) {}
41-
| ^^^^^^^^^^^^ ------- -------
41+
| ^^^^^^^^^^^^ -------
4242

4343
error[E0308]: arguments to this function are incorrect
4444
--> $DIR/invalid_arguments.rs:18:3
@@ -66,7 +66,7 @@ note: function defined here
6666
--> $DIR/invalid_arguments.rs:7:4
6767
|
6868
LL | fn two_arg_diff(_a: i32, _b: f32) {}
69-
| ^^^^^^^^^^^^ ------- -------
69+
| ^^^^^^^^^^^^ -------
7070

7171
error[E0308]: mismatched types
7272
--> $DIR/invalid_arguments.rs:20:16
@@ -80,7 +80,7 @@ note: function defined here
8080
--> $DIR/invalid_arguments.rs:7:4
8181
|
8282
LL | fn two_arg_diff(_a: i32, _b: f32) {}
83-
| ^^^^^^^^^^^^ ------- -------
83+
| ^^^^^^^^^^^^ -------
8484

8585
error[E0308]: arguments to this function are incorrect
8686
--> $DIR/invalid_arguments.rs:21:3
@@ -108,7 +108,7 @@ note: function defined here
108108
--> $DIR/invalid_arguments.rs:8:4
109109
|
110110
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
111-
| ^^^^^^^^^^^^^^ ------- ------- --------
111+
| ^^^^^^^^^^^^^^ -------
112112

113113
error[E0308]: mismatched types
114114
--> $DIR/invalid_arguments.rs:25:21
@@ -122,7 +122,7 @@ note: function defined here
122122
--> $DIR/invalid_arguments.rs:8:4
123123
|
124124
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
125-
| ^^^^^^^^^^^^^^ ------- ------- --------
125+
| ^^^^^^^^^^^^^^ -------
126126

127127
error[E0308]: mismatched types
128128
--> $DIR/invalid_arguments.rs:26:26
@@ -136,7 +136,7 @@ note: function defined here
136136
--> $DIR/invalid_arguments.rs:8:4
137137
|
138138
LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {}
139-
| ^^^^^^^^^^^^^^ ------- ------- --------
139+
| ^^^^^^^^^^^^^^ --------
140140

141141
error[E0308]: arguments to this function are incorrect
142142
--> $DIR/invalid_arguments.rs:28:3
@@ -207,7 +207,7 @@ note: function defined here
207207
--> $DIR/invalid_arguments.rs:9:4
208208
|
209209
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
210-
| ^^^^^^^^^^^^^^^^ ------- ------- --------
210+
| ^^^^^^^^^^^^^^^^ -------
211211

212212
error[E0308]: mismatched types
213213
--> $DIR/invalid_arguments.rs:35:23
@@ -221,7 +221,7 @@ note: function defined here
221221
--> $DIR/invalid_arguments.rs:9:4
222222
|
223223
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
224-
| ^^^^^^^^^^^^^^^^ ------- ------- --------
224+
| ^^^^^^^^^^^^^^^^ -------
225225

226226
error[E0308]: mismatched types
227227
--> $DIR/invalid_arguments.rs:36:26
@@ -235,7 +235,7 @@ note: function defined here
235235
--> $DIR/invalid_arguments.rs:9:4
236236
|
237237
LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {}
238-
| ^^^^^^^^^^^^^^^^ ------- ------- --------
238+
| ^^^^^^^^^^^^^^^^ --------
239239

240240
error[E0308]: arguments to this function are incorrect
241241
--> $DIR/invalid_arguments.rs:38:3

tests/ui/argument-suggestions/too-long.stderr

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,9 @@ note: method defined here
1111
|
1212
LL | fn foo(
1313
| ^^^
14-
LL | &self,
15-
LL | a: i32,
16-
| ------
17-
LL | b: i32,
18-
| ------
19-
LL | c: i32,
20-
| ------
21-
LL | d: i32,
22-
| ------
23-
LL | e: i32,
24-
| ------
14+
...
2515
LL | f: i32,
2616
| ------
27-
LL | g: i32,
28-
| ------
29-
LL | h: i32,
30-
| ------
31-
LL | i: i32,
32-
| ------
33-
LL | j: i32,
34-
| ------
35-
LL | k: i32,
36-
| ------
37-
LL | l: i32,
38-
| ------
3917
help: consider dereferencing the borrow
4018
|
4119
LL | qux.foo(a, b, c, d, e, *f, g, h, i, j, k, l);

tests/ui/async-await/coroutine-desc.stderr

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ note: function defined here
1414
--> $DIR/coroutine-desc.rs:8:4
1515
|
1616
LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {}
17-
| ^^^ - ----- -----
18-
| | | |
19-
| | | this parameter needs to match the `async` block type of `f1`
20-
| | `f2` needs to match the type of this parameter
21-
| `f1` and `f2` all reference this parameter F
17+
| ^^^ -----
2218

2319
error[E0308]: mismatched types
2420
--> $DIR/coroutine-desc.rs:12:16
@@ -35,11 +31,7 @@ note: function defined here
3531
--> $DIR/coroutine-desc.rs:8:4
3632
|
3733
LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {}
38-
| ^^^ - ----- -----
39-
| | | |
40-
| | | this parameter needs to match the future type of `f1`
41-
| | `f2` needs to match the type of this parameter
42-
| `f1` and `f2` all reference this parameter F
34+
| ^^^ -----
4335

4436
error[E0308]: mismatched types
4537
--> $DIR/coroutine-desc.rs:14:26
@@ -57,11 +49,7 @@ note: function defined here
5749
--> $DIR/coroutine-desc.rs:8:4
5850
|
5951
LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {}
60-
| ^^^ - ----- -----
61-
| | | |
62-
| | | this parameter needs to match the `async` closure body type of `f1`
63-
| | `f2` needs to match the type of this parameter
64-
| `f1` and `f2` all reference this parameter F
52+
| ^^^ -----
6553

6654
error: aborting due to 3 previous errors
6755

tests/ui/coercion/coerce-reborrow-multi-arg-fail.stderr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ note: function defined here
1313
--> $DIR/coerce-reborrow-multi-arg-fail.rs:1:4
1414
|
1515
LL | fn test<T>(_a: T, _b: T) {}
16-
| ^^^^ - ----- -----
17-
| | | |
18-
| | | this parameter needs to match the `&mut {integer}` type of `_a`
19-
| | `_b` needs to match the type of this parameter
20-
| `_a` and `_b` all reference this parameter T
16+
| ^^^^ -----
2117

2218
error: aborting due to 1 previous error
2319

tests/ui/coercion/coerce-to-bang.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note: function defined here
1212
--> $DIR/coerce-to-bang.rs:3:4
1313
|
1414
LL | fn foo(x: usize, y: !, z: usize) { }
15-
| ^^^ -------- ---- --------
15+
| ^^^ ----
1616

1717
error[E0308]: mismatched types
1818
--> $DIR/coerce-to-bang.rs:18:13
@@ -28,7 +28,7 @@ note: function defined here
2828
--> $DIR/coerce-to-bang.rs:3:4
2929
|
3030
LL | fn foo(x: usize, y: !, z: usize) { }
31-
| ^^^ -------- ---- --------
31+
| ^^^ ----
3232

3333
error[E0308]: mismatched types
3434
--> $DIR/coerce-to-bang.rs:26:12
@@ -44,7 +44,7 @@ note: function defined here
4444
--> $DIR/coerce-to-bang.rs:3:4
4545
|
4646
LL | fn foo(x: usize, y: !, z: usize) { }
47-
| ^^^ -------- ---- --------
47+
| ^^^ ----
4848

4949
error[E0308]: mismatched types
5050
--> $DIR/coerce-to-bang.rs:36:12
@@ -60,7 +60,7 @@ note: function defined here
6060
--> $DIR/coerce-to-bang.rs:3:4
6161
|
6262
LL | fn foo(x: usize, y: !, z: usize) { }
63-
| ^^^ -------- ---- --------
63+
| ^^^ ----
6464

6565
error[E0308]: mismatched types
6666
--> $DIR/coerce-to-bang.rs:45:12
@@ -76,7 +76,7 @@ note: function defined here
7676
--> $DIR/coerce-to-bang.rs:3:4
7777
|
7878
LL | fn foo(x: usize, y: !, z: usize) { }
79-
| ^^^ -------- ---- --------
79+
| ^^^ ----
8080

8181
error[E0308]: mismatched types
8282
--> $DIR/coerce-to-bang.rs:50:21

tests/ui/fn/fn-item-type.stderr

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ note: function defined here
1414
--> $DIR/fn-item-type.rs:11:4
1515
|
1616
LL | fn eq<T>(x: T, y: T) {}
17-
| ^^ - ---- ----
18-
| | | |
19-
| | | this parameter needs to match the fn item type of `x`
20-
| | `y` needs to match the type of this parameter
21-
| `x` and `y` all reference this parameter T
17+
| ^^ ----
2218
= help: consider casting both fn items to fn pointers using `as fn(isize) -> isize`
2319

2420
error[E0308]: mismatched types
@@ -37,11 +33,7 @@ note: function defined here
3733
--> $DIR/fn-item-type.rs:11:4
3834
|
3935
LL | fn eq<T>(x: T, y: T) {}
40-
| ^^ - ---- ----
41-
| | | |
42-
| | | this parameter needs to match the fn item type of `x`
43-
| | `y` needs to match the type of this parameter
44-
| `x` and `y` all reference this parameter T
36+
| ^^ ----
4537
= help: consider casting both fn items to fn pointers using `as fn(isize) -> isize`
4638

4739
error[E0308]: mismatched types
@@ -60,11 +52,7 @@ note: function defined here
6052
--> $DIR/fn-item-type.rs:11:4
6153
|
6254
LL | fn eq<T>(x: T, y: T) {}
63-
| ^^ - ---- ----
64-
| | | |
65-
| | | this parameter needs to match the fn item type of `x`
66-
| | `y` needs to match the type of this parameter
67-
| `x` and `y` all reference this parameter T
55+
| ^^ ----
6856
= help: consider casting both fn items to fn pointers using `as fn(isize) -> isize`
6957

7058
error[E0308]: mismatched types
@@ -83,11 +71,7 @@ note: function defined here
8371
--> $DIR/fn-item-type.rs:11:4
8472
|
8573
LL | fn eq<T>(x: T, y: T) {}
86-
| ^^ - ---- ----
87-
| | | |
88-
| | | this parameter needs to match the fn item type of `x`
89-
| | `y` needs to match the type of this parameter
90-
| `x` and `y` all reference this parameter T
74+
| ^^ ----
9175
= help: consider casting both fn items to fn pointers using `as fn()`
9276

9377
error[E0308]: mismatched types
@@ -106,11 +90,7 @@ note: function defined here
10690
--> $DIR/fn-item-type.rs:11:4
10791
|
10892
LL | fn eq<T>(x: T, y: T) {}
109-
| ^^ - ---- ----
110-
| | | |
111-
| | | this parameter needs to match the fn item type of `x`
112-
| | `y` needs to match the type of this parameter
113-
| `x` and `y` all reference this parameter T
93+
| ^^ ----
11494

11595
error: aborting due to 5 previous errors
11696

tests/ui/mismatched_types/generic-mismatch-reporting-issue-116615.stderr

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ note: function defined here
1111
--> $DIR/generic-mismatch-reporting-issue-116615.rs:1:4
1212
|
1313
LL | fn foo<T>(a: T, b: T) {}
14-
| ^^^ - ---- ----
15-
| | | |
16-
| | | this parameter needs to match the integer type of `a`
17-
| | `b` needs to match the type of this parameter
18-
| `a` and `b` all reference this parameter T
14+
| ^^^ ----
1915

2016
error[E0308]: arguments to this function are incorrect
2117
--> $DIR/generic-mismatch-reporting-issue-116615.rs:8:5

tests/ui/parser/issues/issue-93282.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ note: function defined here
4343
--> $DIR/issue-93282.rs:7:4
4444
|
4545
LL | fn bar(a: usize, b: usize) -> usize {
46-
| ^^^ -------- --------
46+
| ^^^ --------
4747

4848
error: aborting due to 4 previous errors
4949

tests/ui/span/issue-34264.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ note: function defined here
7777
--> $DIR/issue-34264.rs:3:4
7878
|
7979
LL | fn bar(x, y: usize) {}
80-
| ^^^ - --------
80+
| ^^^ --------
8181

8282
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
8383
--> $DIR/issue-34264.rs:10:5

0 commit comments

Comments
 (0)