Skip to content

Commit a5c039c

Browse files
committed
Auto merge of rust-lang#98264 - compiler-errors:missing-arg-placeholder, r=jackh726
Make missing argument placeholder more obvious that it's a placeholder Use `/* ty */` instead of `{ty}`, since people might be misled into thinking that this is valid syntax, and not just a diagnostic placeholder. Fixes rust-lang#96880
2 parents 9a0b774 + 4400a26 commit a5c039c

22 files changed

+114
-112
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
955955
let input_ty = self.resolve_vars_if_possible(expected_ty);
956956
if input_ty.is_unit() {
957957
"()".to_string()
958+
} else if !input_ty.is_ty_var() {
959+
format!("/* {} */", input_ty)
958960
} else {
959-
format!("{{{}}}", input_ty)
961+
"/* value */".to_string()
960962
}
961963
};
962964
suggestion += &suggestion_text;

src/test/ui/argument-suggestions/basic.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ LL | fn missing(_i: u32) {}
4141
| ^^^^^^^ -------
4242
help: provide the argument
4343
|
44-
LL | missing({u32});
45-
| ~~~~~~~~~~~~~~
44+
LL | missing(/* u32 */);
45+
| ~~~~~~~~~~~~~~~~~~
4646

4747
error[E0308]: arguments to this function are incorrect
4848
--> $DIR/basic.rs:23:5
@@ -94,8 +94,8 @@ LL | let closure = |x| x;
9494
| ^^^
9595
help: provide the argument
9696
|
97-
LL | closure({_});
98-
| ~~~~~~~~~~~~
97+
LL | closure(/* value */);
98+
| ~~~~~~~~~~~~~~~~~~~~
9999

100100
error: aborting due to 6 previous errors
101101

src/test/ui/argument-suggestions/complex.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {}
1111
| ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ------
1212
help: did you mean
1313
|
14-
LL | complex({u32}, &"", {E}, F::X2, G{}, X {}, Y {}, Z {});
15-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {});
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616

1717
error: aborting due to previous error
1818

src/test/ui/argument-suggestions/issue-96638.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | fn f(_: usize, _: &usize, _: usize) {}
1111
| ^ -------- --------- --------
1212
help: provide the argument
1313
|
14-
LL | f({usize}, &x, {usize});
15-
| ~~~~~~~~~~~~~~~~~~~~~~~
14+
LL | f(/* usize */, &x, /* usize */);
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616

1717
error: aborting due to previous error
1818

src/test/ui/argument-suggestions/issue-97197.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}
1111
| ^ ------ -------- -------- -------- -------- ------
1212
help: provide the arguments
1313
|
14-
LL | g((), {bool}, {bool}, {bool}, {bool}, ());
15-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
LL | g((), /* bool */, /* bool */, /* bool */, /* bool */, ());
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616

1717
error: aborting due to previous error
1818

src/test/ui/argument-suggestions/issue-97484.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ LL + foo(&&A, B, C, D, E, F, G);
1919
|
2020
help: remove the extra arguments
2121
|
22-
LL | foo(&&A, D, {&E}, G);
23-
| ~~~~~~~~~~~~~~~~~~~~
22+
LL | foo(&&A, D, /* &E */, G);
23+
| ~~~~~~~~~~~~~~~~~~~~~~~~
2424

2525
error: aborting due to previous error
2626

src/test/ui/argument-suggestions/missing_arguments.stderr

+38-38
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | fn one_arg(_a: i32) {}
1111
| ^^^^^^^ -------
1212
help: provide the argument
1313
|
14-
LL | one_arg({i32});
15-
| ~~~~~~~~~~~~~~
14+
LL | one_arg(/* i32 */);
15+
| ~~~~~~~~~~~~~~~~~~
1616

1717
error[E0061]: this function takes 2 arguments but 0 arguments were supplied
1818
--> $DIR/missing_arguments.rs:14:3
@@ -27,8 +27,8 @@ LL | fn two_same(_a: i32, _b: i32) {}
2727
| ^^^^^^^^ ------- -------
2828
help: provide the arguments
2929
|
30-
LL | two_same({i32}, {i32});
31-
| ~~~~~~~~~~~~~~~~~~~~~~
30+
LL | two_same(/* i32 */, /* i32 */);
31+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3232

3333
error[E0061]: this function takes 2 arguments but 1 argument was supplied
3434
--> $DIR/missing_arguments.rs:15:3
@@ -43,8 +43,8 @@ LL | fn two_same(_a: i32, _b: i32) {}
4343
| ^^^^^^^^ ------- -------
4444
help: provide the argument
4545
|
46-
LL | two_same(1, {i32});
47-
| ~~~~~~~~~~~~~~~~~~
46+
LL | two_same(1, /* i32 */);
47+
| ~~~~~~~~~~~~~~~~~~~~~~
4848

4949
error[E0061]: this function takes 2 arguments but 0 arguments were supplied
5050
--> $DIR/missing_arguments.rs:16:3
@@ -59,8 +59,8 @@ LL | fn two_diff(_a: i32, _b: f32) {}
5959
| ^^^^^^^^ ------- -------
6060
help: provide the arguments
6161
|
62-
LL | two_diff({i32}, {f32});
63-
| ~~~~~~~~~~~~~~~~~~~~~~
62+
LL | two_diff(/* i32 */, /* f32 */);
63+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6464

6565
error[E0061]: this function takes 2 arguments but 1 argument was supplied
6666
--> $DIR/missing_arguments.rs:17:3
@@ -75,8 +75,8 @@ LL | fn two_diff(_a: i32, _b: f32) {}
7575
| ^^^^^^^^ ------- -------
7676
help: provide the argument
7777
|
78-
LL | two_diff(1, {f32});
79-
| ~~~~~~~~~~~~~~~~~~
78+
LL | two_diff(1, /* f32 */);
79+
| ~~~~~~~~~~~~~~~~~~~~~~
8080

8181
error[E0061]: this function takes 2 arguments but 1 argument was supplied
8282
--> $DIR/missing_arguments.rs:18:3
@@ -91,8 +91,8 @@ LL | fn two_diff(_a: i32, _b: f32) {}
9191
| ^^^^^^^^ ------- -------
9292
help: provide the argument
9393
|
94-
LL | two_diff({i32}, 1.0);
95-
| ~~~~~~~~~~~~~~~~~~~~
94+
LL | two_diff(/* i32 */, 1.0);
95+
| ~~~~~~~~~~~~~~~~~~~~~~~~
9696

9797
error[E0061]: this function takes 3 arguments but 0 arguments were supplied
9898
--> $DIR/missing_arguments.rs:21:3
@@ -107,8 +107,8 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {}
107107
| ^^^^^^^^^^ ------- ------- -------
108108
help: provide the arguments
109109
|
110-
LL | three_same({i32}, {i32}, {i32});
111-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110+
LL | three_same(/* i32 */, /* i32 */, /* i32 */);
111+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112112

113113
error[E0061]: this function takes 3 arguments but 1 argument was supplied
114114
--> $DIR/missing_arguments.rs:22:3
@@ -123,8 +123,8 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {}
123123
| ^^^^^^^^^^ ------- ------- -------
124124
help: provide the arguments
125125
|
126-
LL | three_same(1, {i32}, {i32});
127-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
126+
LL | three_same(1, /* i32 */, /* i32 */);
127+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128128

129129
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
130130
--> $DIR/missing_arguments.rs:23:3
@@ -139,8 +139,8 @@ LL | fn three_same(_a: i32, _b: i32, _c: i32) {}
139139
| ^^^^^^^^^^ ------- ------- -------
140140
help: provide the argument
141141
|
142-
LL | three_same(1, 1, {i32});
143-
| ~~~~~~~~~~~~~~~~~~~~~~~
142+
LL | three_same(1, 1, /* i32 */);
143+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
144144

145145
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
146146
--> $DIR/missing_arguments.rs:26:3
@@ -155,8 +155,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {}
155155
| ^^^^^^^^^^ ------- ------- --------
156156
help: provide the argument
157157
|
158-
LL | three_diff({i32}, 1.0, "");
159-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
158+
LL | three_diff(/* i32 */, 1.0, "");
159+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160160

161161
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
162162
--> $DIR/missing_arguments.rs:27:3
@@ -171,8 +171,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {}
171171
| ^^^^^^^^^^ ------- ------- --------
172172
help: provide the argument
173173
|
174-
LL | three_diff(1, {f32}, "");
175-
| ~~~~~~~~~~~~~~~~~~~~~~~~
174+
LL | three_diff(1, /* f32 */, "");
175+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176176

177177
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
178178
--> $DIR/missing_arguments.rs:28:3
@@ -187,8 +187,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {}
187187
| ^^^^^^^^^^ ------- ------- --------
188188
help: provide the argument
189189
|
190-
LL | three_diff(1, 1.0, {&str});
191-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
190+
LL | three_diff(1, 1.0, /* &str */);
191+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192192

193193
error[E0061]: this function takes 3 arguments but 1 argument was supplied
194194
--> $DIR/missing_arguments.rs:29:3
@@ -203,8 +203,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {}
203203
| ^^^^^^^^^^ ------- ------- --------
204204
help: provide the arguments
205205
|
206-
LL | three_diff({i32}, {f32}, "");
207-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
206+
LL | three_diff(/* i32 */, /* f32 */, "");
207+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208208

209209
error[E0061]: this function takes 3 arguments but 1 argument was supplied
210210
--> $DIR/missing_arguments.rs:30:3
@@ -222,8 +222,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {}
222222
| ^^^^^^^^^^ ------- ------- --------
223223
help: provide the arguments
224224
|
225-
LL | three_diff({i32}, 1.0, {&str});
226-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225+
LL | three_diff(/* i32 */, 1.0, /* &str */);
226+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227227

228228
error[E0061]: this function takes 3 arguments but 1 argument was supplied
229229
--> $DIR/missing_arguments.rs:31:3
@@ -238,8 +238,8 @@ LL | fn three_diff(_a: i32, _b: f32, _c: &str) {}
238238
| ^^^^^^^^^^ ------- ------- --------
239239
help: provide the arguments
240240
|
241-
LL | three_diff(1, {f32}, {&str});
242-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241+
LL | three_diff(1, /* f32 */, /* &str */);
242+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243243

244244
error[E0061]: this function takes 4 arguments but 0 arguments were supplied
245245
--> $DIR/missing_arguments.rs:34:3
@@ -254,8 +254,8 @@ LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {}
254254
| ^^^^^^^^^^^^^ ------- ------- ------- --------
255255
help: provide the arguments
256256
|
257-
LL | four_repeated({i32}, {f32}, {f32}, {&str});
258-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257+
LL | four_repeated(/* i32 */, /* f32 */, /* f32 */, /* &str */);
258+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259259

260260
error[E0061]: this function takes 4 arguments but 2 arguments were supplied
261261
--> $DIR/missing_arguments.rs:35:3
@@ -270,8 +270,8 @@ LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {}
270270
| ^^^^^^^^^^^^^ ------- ------- ------- --------
271271
help: provide the arguments
272272
|
273-
LL | four_repeated(1, {f32}, {f32}, "");
274-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273+
LL | four_repeated(1, /* f32 */, /* f32 */, "");
274+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
275275

276276
error[E0061]: this function takes 5 arguments but 0 arguments were supplied
277277
--> $DIR/missing_arguments.rs:38:3
@@ -286,8 +286,8 @@ LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {}
286286
| ^^^^^^^ ------- ------- ------- ------- --------
287287
help: provide the arguments
288288
|
289-
LL | complex({i32}, {f32}, {i32}, {f32}, {&str});
290-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289+
LL | complex(/* i32 */, /* f32 */, /* i32 */, /* f32 */, /* &str */);
290+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291291

292292
error[E0061]: this function takes 5 arguments but 2 arguments were supplied
293293
--> $DIR/missing_arguments.rs:39:3
@@ -302,8 +302,8 @@ LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {}
302302
| ^^^^^^^ ------- ------- ------- ------- --------
303303
help: provide the arguments
304304
|
305-
LL | complex(1, {f32}, {i32}, {f32}, "");
306-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305+
LL | complex(1, /* f32 */, /* i32 */, /* f32 */, "");
306+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307307

308308
error: aborting due to 19 previous errors
309309

src/test/ui/argument-suggestions/mixed_cases.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ LL | fn two_args(_a: i32, _b: f32) {}
1313
| ^^^^^^^^ ------- -------
1414
help: remove the extra argument
1515
|
16-
LL | two_args(1, {f32});
17-
| ~~~~~~~~~~~~~~~~~~
16+
LL | two_args(1, /* f32 */);
17+
| ~~~~~~~~~~~~~~~~~~~~~~
1818

1919
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
2020
--> $DIR/mixed_cases.rs:11:3
@@ -32,8 +32,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {}
3232
| ^^^^^^^^^^ ------- ------- --------
3333
help: did you mean
3434
|
35-
LL | three_args(1, {f32}, "");
36-
| ~~~~~~~~~~~~~~~~~~~~~~~~
35+
LL | three_args(1, /* f32 */, "");
36+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3737

3838
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
3939
--> $DIR/mixed_cases.rs:14:3
@@ -51,8 +51,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {}
5151
| ^^^^^^^^^^ ------- ------- --------
5252
help: provide the argument
5353
|
54-
LL | three_args(1, {f32}, {&str});
55-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54+
LL | three_args(1, /* f32 */, /* &str */);
55+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5656

5757
error[E0308]: arguments to this function are incorrect
5858
--> $DIR/mixed_cases.rs:17:3
@@ -69,8 +69,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {}
6969
| ^^^^^^^^^^ ------- ------- --------
7070
help: did you mean
7171
|
72-
LL | three_args(1, {f32}, "");
73-
| ~~~~~~~~~~~~~~~~~~~~~~~~
72+
LL | three_args(1, /* f32 */, "");
73+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7474

7575
error[E0308]: arguments to this function are incorrect
7676
--> $DIR/mixed_cases.rs:20:3
@@ -88,8 +88,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {}
8888
| ^^^^^^^^^^ ------- ------- --------
8989
help: swap these arguments
9090
|
91-
LL | three_args(1, {f32}, "");
92-
| ~~~~~~~~~~~~~~~~~~~~~~~~
91+
LL | three_args(1, /* f32 */, "");
92+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9393

9494
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
9595
--> $DIR/mixed_cases.rs:23:3
@@ -108,8 +108,8 @@ LL | fn three_args(_a: i32, _b: f32, _c: &str) {}
108108
| ^^^^^^^^^^ ------- ------- --------
109109
help: did you mean
110110
|
111-
LL | three_args(1, {f32}, "");
112-
| ~~~~~~~~~~~~~~~~~~~~~~~~
111+
LL | three_args(1, /* f32 */, "");
112+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113113

114114
error: aborting due to 6 previous errors
115115

src/test/ui/c-variadic/variadic-ffi-1.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ LL | fn foo(f: isize, x: u8, ...);
1717
| ^^^
1818
help: provide the arguments
1919
|
20-
LL | foo({isize}, {u8});
21-
| ~~~~~~~~~~~~~~~~~~
20+
LL | foo(/* isize */, /* u8 */);
21+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
2222

2323
error[E0060]: this function takes at least 2 arguments but 1 argument was supplied
2424
--> $DIR/variadic-ffi-1.rs:21:9
@@ -33,8 +33,8 @@ LL | fn foo(f: isize, x: u8, ...);
3333
| ^^^
3434
help: provide the argument
3535
|
36-
LL | foo(1, {u8});
37-
| ~~~~~~~~~~~~
36+
LL | foo(1, /* u8 */);
37+
| ~~~~~~~~~~~~~~~~
3838

3939
error[E0308]: mismatched types
4040
--> $DIR/variadic-ffi-1.rs:23:56

src/test/ui/error-codes/E0057.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | let f = |x| x * 3;
1111
| ^^^
1212
help: provide the argument
1313
|
14-
LL | let a = f({_});
15-
| ~~~~~~
14+
LL | let a = f(/* value */);
15+
| ~~~~~~~~~~~~~~
1616

1717
error[E0057]: this function takes 1 argument but 2 arguments were supplied
1818
--> $DIR/E0057.rs:5:13

src/test/ui/error-codes/E0060.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | fn printf(_: *const u8, ...) -> u32;
1111
| ^^^^^^
1212
help: provide the argument
1313
|
14-
LL | unsafe { printf({*const u8}); }
15-
| ~~~~~~~~~~~~~~~~~~~
14+
LL | unsafe { printf(/* *const u8 */); }
15+
| ~~~~~~~~~~~~~~~~~~~~~~~
1616

1717
error: aborting due to previous error
1818

0 commit comments

Comments
 (0)