Skip to content

Commit 71c893d

Browse files
Fix to use #n format
1 parent ffcca4f commit 71c893d

36 files changed

+107
-119
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,18 +1015,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10151015
.is_some_and(|first| matches!(first, Error::Extra(arg_idx) if arg_idx.index() == 0));
10161016
let mut suggestions = vec![];
10171017

1018-
// Convert the given number into the corresponding ordinal
1019-
// This is copied from rustc_resolve::diagnostics::ordinalize because it is too much to link rustc_resolve for this small function.
1020-
fn ordinalize(v: usize) -> String {
1021-
let suffix = match ((11..=13).contains(&(v % 100)), v % 10) {
1022-
(false, 1) => "st",
1023-
(false, 2) => "nd",
1024-
(false, 3) => "rd",
1025-
_ => "th",
1026-
};
1027-
format!("{v}{suffix}")
1028-
}
1029-
10301018
while let Some(error) = errors.next() {
10311019
only_extras_so_far &= matches!(error, Error::Extra(_));
10321020

@@ -1071,7 +1059,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10711059
let ord = if provided_arg_tys.len() == 1 {
10721060
"".to_string()
10731061
} else {
1074-
format!("{} ", ordinalize(arg_idx.as_usize() + 1))
1062+
format!("#{} ", arg_idx.as_usize() + 1)
10751063
};
10761064
labels.push((
10771065
provided_span,
@@ -1160,7 +1148,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11601148
let ord = if formal_and_expected_inputs.len() == 1 {
11611149
"an".to_string()
11621150
} else {
1163-
ordinalize(expected_idx.as_usize() + 1)
1151+
format!("#{}", expected_idx.as_usize() + 1)
11641152
};
11651153
labels.push((span, format!("{ord} argument{rendered} is missing")));
11661154

tests/ui/argument-suggestions/extern-fn-arg-names.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0061]: this function takes 2 arguments but 1 argument was supplied
88
--> $DIR/extern-fn-arg-names.rs:7:5
99
|
1010
LL | dstfn(1);
11-
| ^^^^^--- 2nd argument is missing
11+
| ^^^^^--- #2 argument is missing
1212
|
1313
note: function defined here
1414
--> $DIR/extern-fn-arg-names.rs:2:8

tests/ui/argument-suggestions/extra_arguments.stderr

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
1717
--> $DIR/extra_arguments.rs:20:3
1818
|
1919
LL | empty(1, 1);
20-
| ^^^^^ - - unexpected 2nd argument of type `{integer}`
20+
| ^^^^^ - - unexpected #2 argument of type `{integer}`
2121
| |
22-
| unexpected 1st argument of type `{integer}`
22+
| unexpected #1 argument of type `{integer}`
2323
|
2424
note: function defined here
2525
--> $DIR/extra_arguments.rs:1:4
@@ -38,7 +38,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
3838
LL | one_arg(1, 1);
3939
| ^^^^^^^ ---
4040
| | |
41-
| | unexpected 2nd argument of type `{integer}`
41+
| | unexpected #2 argument of type `{integer}`
4242
| help: remove the extra argument
4343
|
4444
note: function defined here
@@ -53,7 +53,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
5353
LL | one_arg(1, "");
5454
| ^^^^^^^ ----
5555
| | |
56-
| | unexpected 2nd argument of type `&'static str`
56+
| | unexpected #2 argument of type `&'static str`
5757
| help: remove the extra argument
5858
|
5959
note: function defined here
@@ -66,9 +66,9 @@ error[E0061]: this function takes 1 argument but 3 arguments were supplied
6666
--> $DIR/extra_arguments.rs:24:3
6767
|
6868
LL | one_arg(1, "", 1.0);
69-
| ^^^^^^^ -- --- unexpected 3rd argument of type `{float}`
69+
| ^^^^^^^ -- --- unexpected #3 argument of type `{float}`
7070
| |
71-
| unexpected 2nd argument of type `&'static str`
71+
| unexpected #2 argument of type `&'static str`
7272
|
7373
note: function defined here
7474
--> $DIR/extra_arguments.rs:2:4
@@ -87,7 +87,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
8787
LL | two_arg_same(1, 1, 1);
8888
| ^^^^^^^^^^^^ ---
8989
| | |
90-
| | unexpected 3rd argument of type `{integer}`
90+
| | unexpected #3 argument of type `{integer}`
9191
| help: remove the extra argument
9292
|
9393
note: function defined here
@@ -102,7 +102,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
102102
LL | two_arg_same(1, 1, 1.0);
103103
| ^^^^^^^^^^^^ -----
104104
| | |
105-
| | unexpected 3rd argument of type `{float}`
105+
| | unexpected #3 argument of type `{float}`
106106
| help: remove the extra argument
107107
|
108108
note: function defined here
@@ -117,7 +117,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
117117
LL | two_arg_diff(1, 1, "");
118118
| ^^^^^^^^^^^^ ---
119119
| | |
120-
| | unexpected 2nd argument of type `{integer}`
120+
| | unexpected #2 argument of type `{integer}`
121121
| help: remove the extra argument
122122
|
123123
note: function defined here
@@ -132,7 +132,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
132132
LL | two_arg_diff(1, "", "");
133133
| ^^^^^^^^^^^^ ----
134134
| | |
135-
| | unexpected 3rd argument of type `&'static str`
135+
| | unexpected #3 argument of type `&'static str`
136136
| help: remove the extra argument
137137
|
138138
note: function defined here
@@ -145,9 +145,9 @@ error[E0061]: this function takes 2 arguments but 4 arguments were supplied
145145
--> $DIR/extra_arguments.rs:31:3
146146
|
147147
LL | two_arg_diff(1, 1, "", "");
148-
| ^^^^^^^^^^^^ - -- unexpected 4th argument of type `&'static str`
148+
| ^^^^^^^^^^^^ - -- unexpected #4 argument of type `&'static str`
149149
| |
150-
| unexpected 2nd argument of type `{integer}`
150+
| unexpected #2 argument of type `{integer}`
151151
|
152152
note: function defined here
153153
--> $DIR/extra_arguments.rs:4:4
@@ -164,9 +164,9 @@ error[E0061]: this function takes 2 arguments but 4 arguments were supplied
164164
--> $DIR/extra_arguments.rs:32:3
165165
|
166166
LL | two_arg_diff(1, "", 1, "");
167-
| ^^^^^^^^^^^^ - -- unexpected 4th argument of type `&'static str`
167+
| ^^^^^^^^^^^^ - -- unexpected #4 argument of type `&'static str`
168168
| |
169-
| unexpected 3rd argument of type `{integer}`
169+
| unexpected #3 argument of type `{integer}`
170170
|
171171
note: function defined here
172172
--> $DIR/extra_arguments.rs:4:4
@@ -185,7 +185,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
185185
LL | two_arg_same(1, 1, "");
186186
| ^^^^^^^^^^^^ --------
187187
| | |
188-
| | unexpected 3rd argument of type `&'static str`
188+
| | unexpected #3 argument of type `&'static str`
189189
| help: remove the extra argument
190190
|
191191
note: function defined here
@@ -200,7 +200,7 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
200200
LL | two_arg_diff(1, 1, "");
201201
| ^^^^^^^^^^^^ ---
202202
| | |
203-
| | unexpected 2nd argument of type `{integer}`
203+
| | unexpected #2 argument of type `{integer}`
204204
| help: remove the extra argument
205205
|
206206
note: function defined here
@@ -221,7 +221,7 @@ LL | | ""
221221
| | --
222222
| |_____||
223223
| |help: remove the extra argument
224-
| unexpected 3rd argument of type `&'static str`
224+
| unexpected #3 argument of type `&'static str`
225225
|
226226
note: function defined here
227227
--> $DIR/extra_arguments.rs:3:4
@@ -239,7 +239,7 @@ LL | 1,
239239
LL | | 1,
240240
| | -
241241
| | |
242-
| |_____unexpected 2nd argument of type `{integer}`
242+
| |_____unexpected #2 argument of type `{integer}`
243243
| help: remove the extra argument
244244
|
245245
note: function defined here
@@ -252,12 +252,12 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
252252
--> $DIR/extra_arguments.rs:8:9
253253
|
254254
LL | empty($x, 1);
255-
| ^^^^^ - unexpected 2nd argument of type `{integer}`
255+
| ^^^^^ - unexpected #2 argument of type `{integer}`
256256
...
257257
LL | foo!(1, ~);
258258
| ----------
259259
| | |
260-
| | unexpected 1st argument of type `{integer}`
260+
| | unexpected #1 argument of type `{integer}`
261261
| in this macro invocation
262262
|
263263
note: function defined here
@@ -271,12 +271,12 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
271271
--> $DIR/extra_arguments.rs:14:9
272272
|
273273
LL | empty(1, $y);
274-
| ^^^^^ - unexpected 1st argument of type `{integer}`
274+
| ^^^^^ - unexpected #1 argument of type `{integer}`
275275
...
276276
LL | foo!(~, 1);
277277
| ----------
278278
| | |
279-
| | unexpected 2nd argument of type `{integer}`
279+
| | unexpected #2 argument of type `{integer}`
280280
| in this macro invocation
281281
|
282282
note: function defined here
@@ -295,8 +295,8 @@ LL | empty($x, $y);
295295
LL | foo!(1, 1);
296296
| ----------
297297
| | | |
298-
| | | unexpected 2nd argument of type `{integer}`
299-
| | unexpected 1st argument of type `{integer}`
298+
| | | unexpected #2 argument of type `{integer}`
299+
| | unexpected #1 argument of type `{integer}`
300300
| in this macro invocation
301301
|
302302
note: function defined here
@@ -312,7 +312,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
312312
LL | one_arg(1, panic!());
313313
| ^^^^^^^ ----------
314314
| | |
315-
| | unexpected 2nd argument
315+
| | unexpected #2 argument
316316
| help: remove the extra argument
317317
|
318318
note: function defined here
@@ -327,7 +327,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
327327
LL | one_arg(panic!(), 1);
328328
| ^^^^^^^ ---
329329
| | |
330-
| | unexpected 2nd argument of type `{integer}`
330+
| | unexpected #2 argument of type `{integer}`
331331
| help: remove the extra argument
332332
|
333333
note: function defined here
@@ -342,7 +342,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
342342
LL | one_arg(stringify!($e), 1);
343343
| ^^^^^^^ ---
344344
| | |
345-
| | unexpected 2nd argument of type `{integer}`
345+
| | unexpected #2 argument of type `{integer}`
346346
| help: remove the extra argument
347347
|
348348
note: function defined here
@@ -357,7 +357,7 @@ error[E0061]: this function takes 1 argument but 2 arguments were supplied
357357
LL | one_arg(for _ in 1.. {}, 1);
358358
| ^^^^^^^ ---
359359
| | |
360-
| | unexpected 2nd argument of type `{integer}`
360+
| | unexpected #2 argument of type `{integer}`
361361
| help: remove the extra argument
362362
|
363363
note: function defined here

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0061]: this function takes 3 arguments but 1 argument was supplied
44
LL | three_diff(T2::new(0));
55
| ^^^^^^^^^^------------
66
| ||
7-
| |1st argument of type `T1` is missing
8-
| 3rd argument of type `T3` is missing
7+
| |#1 argument of type `T1` is missing
8+
| #3 argument of type `T3` is missing
99
|
1010
note: function defined here
1111
--> $DIR/issue-100478.rs:30:4
@@ -63,7 +63,7 @@ LL | foo(
6363
| ^^^
6464
...
6565
LL | p3, p4, p5, p6, p7, p8,
66-
| -- 2nd argument of type `Arc<T2>` is missing
66+
| -- #2 argument of type `Arc<T2>` is missing
6767
|
6868
note: function defined here
6969
--> $DIR/issue-100478.rs:29:4

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0061]: this function takes 6 arguments but 7 arguments were supplied
44
LL | f(C, A, A, A, B, B, C);
55
| ^ - - - - expected `C`, found `B`
66
| | | |
7-
| | | unexpected 4th argument of type `A`
7+
| | | unexpected #4 argument of type `A`
88
| | expected `B`, found `A`
99
| expected `A`, found `C`
1010
|
@@ -64,8 +64,8 @@ error[E0308]: arguments to this function are incorrect
6464
LL | f(A, A, D, D, B, B);
6565
| ^ - - ---- two arguments of type `C` and `C` are missing
6666
| | |
67-
| | unexpected 4th argument of type `D`
68-
| unexpected 3rd argument of type `D`
67+
| | unexpected #4 argument of type `D`
68+
| unexpected #3 argument of type `D`
6969
|
7070
note: function defined here
7171
--> $DIR/issue-101097.rs:6:4

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ error[E0061]: this function takes 0 arguments but 2 arguments were supplied
22
--> $DIR/issue-109425.rs:10:5
33
|
44
LL | f(0, 1,); // f()
5-
| ^ - - unexpected 2nd argument of type `{integer}`
5+
| ^ - - unexpected #2 argument of type `{integer}`
66
| |
7-
| unexpected 1st argument of type `{integer}`
7+
| unexpected #1 argument of type `{integer}`
88
|
99
note: function defined here
1010
--> $DIR/issue-109425.rs:3:4
@@ -21,9 +21,9 @@ error[E0061]: this function takes 1 argument but 3 arguments were supplied
2121
--> $DIR/issue-109425.rs:12:5
2222
|
2323
LL | i(0, 1, 2,); // i(0,)
24-
| ^ - - unexpected 3rd argument of type `{integer}`
24+
| ^ - - unexpected #3 argument of type `{integer}`
2525
| |
26-
| unexpected 2nd argument of type `{integer}`
26+
| unexpected #2 argument of type `{integer}`
2727
|
2828
note: function defined here
2929
--> $DIR/issue-109425.rs:4:4
@@ -40,9 +40,9 @@ error[E0061]: this function takes 1 argument but 3 arguments were supplied
4040
--> $DIR/issue-109425.rs:14:5
4141
|
4242
LL | i(0, 1, 2); // i(0)
43-
| ^ - - unexpected 3rd argument of type `{integer}`
43+
| ^ - - unexpected #3 argument of type `{integer}`
4444
| |
45-
| unexpected 2nd argument of type `{integer}`
45+
| unexpected #2 argument of type `{integer}`
4646
|
4747
note: function defined here
4848
--> $DIR/issue-109425.rs:4:4
@@ -59,9 +59,9 @@ error[E0061]: this function takes 2 arguments but 4 arguments were supplied
5959
--> $DIR/issue-109425.rs:16:5
6060
|
6161
LL | is(0, 1, 2, ""); // is(0, "")
62-
| ^^ - - unexpected 3rd argument of type `{integer}`
62+
| ^^ - - unexpected #3 argument of type `{integer}`
6363
| |
64-
| unexpected 2nd argument of type `{integer}`
64+
| unexpected #2 argument of type `{integer}`
6565
|
6666
note: function defined here
6767
--> $DIR/issue-109425.rs:5:4
@@ -78,9 +78,9 @@ error[E0061]: this function takes 1 argument but 3 arguments were supplied
7878
--> $DIR/issue-109425.rs:18:5
7979
|
8080
LL | s(0, 1, ""); // s("")
81-
| ^ - - unexpected 2nd argument of type `{integer}`
81+
| ^ - - unexpected #2 argument of type `{integer}`
8282
| |
83-
| unexpected 1st argument of type `{integer}`
83+
| unexpected #1 argument of type `{integer}`
8484
|
8585
note: function defined here
8686
--> $DIR/issue-109425.rs:6:4

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ error[E0061]: this function takes 3 arguments but 4 arguments were supplied
2929
--> $DIR/issue-109831.rs:7:5
3030
|
3131
LL | f(A, A, B, C);
32-
| ^ - - - unexpected 4th argument
32+
| ^ - - - unexpected #4 argument
3333
| | |
3434
| | expected `B`, found `A`
3535
| expected `B`, found `A`

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ error[E0061]: this enum variant takes 1 argument but 4 arguments were supplied
44
LL | let _a = Value::Float(
55
| ^^^^^^^^^^^^
66
LL | 0,
7-
| - unexpected 1st argument of type `{integer}`
7+
| - unexpected #1 argument of type `{integer}`
88
LL | None,
99
LL | None,
10-
| ---- unexpected 3rd argument of type `Option<_>`
10+
| ---- unexpected #3 argument of type `Option<_>`
1111
LL | 0,
12-
| - unexpected 4th argument of type `{integer}`
12+
| - unexpected #4 argument of type `{integer}`
1313
|
1414
note: tuple variant defined here
1515
--> $DIR/issue-112507.rs:2:5

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0061]: this function takes 3 arguments but 2 arguments were supplied
44
LL | f(&x, "");
55
| ^ -- -- expected `usize`, found `&str`
66
| |
7-
| 1st argument of type `usize` is missing
7+
| #1 argument of type `usize` is missing
88
|
99
note: function defined here
1010
--> $DIR/issue-96638.rs:1:4

0 commit comments

Comments
 (0)