|
11 | 11 | fn main() { |
12 | 12 | // bad arguments to the format! call |
13 | 13 |
|
14 | | - format!("{}"); //~ ERROR: invalid reference to argument |
| 14 | + // bad number of arguments, see #44954 (originally #15780) |
15 | 15 |
|
16 | | - format!("{1}", 1); //~ ERROR: invalid reference to argument `1` |
17 | | - //~^ ERROR: argument never used |
18 | | - format!("{foo}"); //~ ERROR: no argument named `foo` |
| 16 | + format!("{}"); |
| 17 | + //~^ ERROR: 1 positional argument in format string, but no arguments were given |
19 | 18 |
|
20 | | - format!("", 1, 2); //~ ERROR: multiple unused formatting arguments |
21 | | - format!("{}", 1, 2); //~ ERROR: argument never used |
22 | | - format!("{1}", 1, 2); //~ ERROR: argument never used |
23 | | - format!("{}", 1, foo=2); //~ ERROR: named argument never used |
24 | | - format!("{foo}", 1, foo=2); //~ ERROR: argument never used |
25 | | - format!("", foo=2); //~ ERROR: named argument never used |
| 19 | + format!("{1}", 1); |
| 20 | + //~^ ERROR: 1 positional argument in format string, but there is only 1 argument |
| 21 | + //~^^ ERROR: argument never used |
26 | 22 |
|
27 | | - format!("{foo}", foo=1, foo=2); //~ ERROR: duplicate argument |
28 | | - format!("", foo=1, 2); //~ ERROR: positional arguments cannot follow |
29 | | - |
30 | | - // bad number of arguments, see #15780 |
31 | | - |
32 | | - format!("{0}"); |
33 | | - //~^ ERROR invalid reference to argument `0` (no arguments given) |
| 23 | + format!("{} {}"); |
| 24 | + //~^ ERROR: 2 positional arguments in format string, but no arguments were given |
34 | 25 |
|
35 | 26 | format!("{0} {1}", 1); |
36 | | - //~^ ERROR invalid reference to argument `1` (there is 1 argument) |
| 27 | + //~^ ERROR: 2 positional arguments in format string, but there is only 1 argument |
37 | 28 |
|
38 | 29 | format!("{0} {1} {2}", 1, 2); |
39 | | - //~^ ERROR invalid reference to argument `2` (there are 2 arguments) |
40 | | - |
41 | | - format!("{0} {1}"); |
42 | | - //~^ ERROR invalid reference to argument `0` (no arguments given) |
43 | | - //~^^ ERROR invalid reference to argument `1` (no arguments given) |
| 30 | + //~^ ERROR: 3 positional arguments in format string, but there are only 2 arguments |
| 31 | + |
| 32 | + format!("{} {value} {} {}", 1, value=2); |
| 33 | + //~^ ERROR: invalid reference to positional argument 2 (there are only 2 arguments) |
| 34 | + format!("{name} {value} {} {} {} {} {} {}", 0, name=1, value=2); |
| 35 | + //~^ ERROR: invalid reference to positional arguments 3, 4 and 5 (there are only 3 arguments) |
| 36 | + |
| 37 | + format!("{foo}"); //~ ERROR: no argument named `foo` |
| 38 | + format!("", 1, 2); //~ ERROR: multiple unused formatting arguments |
| 39 | + format!("{}", 1, 2); //~ ERROR: argument never used |
| 40 | + format!("{1}", 1, 2); //~ ERROR: argument never used |
| 41 | + format!("{}", 1, foo=2); //~ ERROR: named argument never used |
| 42 | + format!("{foo}", 1, foo=2); //~ ERROR: argument never used |
| 43 | + format!("", foo=2); //~ ERROR: named argument never used |
| 44 | + |
| 45 | + format!("{foo}", foo=1, foo=2); //~ ERROR: duplicate argument |
| 46 | + format!("", foo=1, 2); //~ ERROR: positional arguments cannot follow |
44 | 47 |
|
45 | 48 | // bad named arguments, #35082 |
46 | 49 |
|
|
0 commit comments