|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 | 11 | fn main() {
|
12 |
| - // bad arguments to the ifmt! call |
| 12 | + // bad arguments to the format! call |
13 | 13 |
|
14 |
| - ifmt!(); //~ ERROR: expects at least one |
15 |
| - ifmt!("{}"); //~ ERROR: invalid reference to argument |
| 14 | + format!(); //~ ERROR: requires at least a format string |
| 15 | + format!("{}"); //~ ERROR: invalid reference to argument |
16 | 16 |
|
17 |
| - ifmt!("{1}", 1); //~ ERROR: invalid reference to argument `1` |
| 17 | + format!("{1}", 1); //~ ERROR: invalid reference to argument `1` |
18 | 18 | //~^ ERROR: argument never used
|
19 |
| - ifmt!("{foo}"); //~ ERROR: no argument named `foo` |
| 19 | + format!("{foo}"); //~ ERROR: no argument named `foo` |
20 | 20 |
|
21 |
| - ifmt!("{}", 1, 2); //~ ERROR: argument never used |
22 |
| - ifmt!("{1}", 1, 2); //~ ERROR: argument never used |
23 |
| - ifmt!("{}", 1, foo=2); //~ ERROR: named argument never used |
24 |
| - ifmt!("{foo}", 1, foo=2); //~ ERROR: argument never used |
25 |
| - ifmt!("", foo=2); //~ ERROR: named argument never used |
| 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 |
26 | 26 |
|
27 |
| - ifmt!("{0:d} {0:s}", 1); //~ ERROR: redeclared with type `s` |
28 |
| - ifmt!("{foo:d} {foo:s}", foo=1); //~ ERROR: redeclared with type `s` |
| 27 | + format!("{0:d} {0:s}", 1); //~ ERROR: redeclared with type `s` |
| 28 | + format!("{foo:d} {foo:s}", foo=1); //~ ERROR: redeclared with type `s` |
29 | 29 |
|
30 |
| - ifmt!("{foo}", foo=1, foo=2); //~ ERROR: duplicate argument |
31 |
| - ifmt!("#"); //~ ERROR: `#` reference used |
32 |
| - ifmt!("", foo=1, 2); //~ ERROR: positional arguments cannot follow |
33 |
| - ifmt!("" 1); //~ ERROR: expected token: `,` |
34 |
| - ifmt!("", 1 1); //~ ERROR: expected token: `,` |
| 30 | + format!("{foo}", foo=1, foo=2); //~ ERROR: duplicate argument |
| 31 | + format!("#"); //~ ERROR: `#` reference used |
| 32 | + format!("", foo=1, 2); //~ ERROR: positional arguments cannot follow |
| 33 | + format!("" 1); //~ ERROR: expected token: `,` |
| 34 | + format!("", 1 1); //~ ERROR: expected token: `,` |
35 | 35 |
|
36 |
| - ifmt!("{0, select, a{} a{} other{}}", "a"); //~ ERROR: duplicate selector |
37 |
| - ifmt!("{0, plural, =1{} =1{} other{}}", 1u); //~ ERROR: duplicate selector |
38 |
| - ifmt!("{0, plural, one{} one{} other{}}", 1u); //~ ERROR: duplicate selector |
| 36 | + format!("{0, select, a{} a{} other{}}", "a"); //~ ERROR: duplicate selector |
| 37 | + format!("{0, plural, =1{} =1{} other{}}", 1u); //~ ERROR: duplicate selector |
| 38 | + format!("{0, plural, one{} one{} other{}}", 1u); //~ ERROR: duplicate selector |
39 | 39 |
|
40 | 40 | // bad syntax of the format string
|
41 | 41 |
|
42 |
| - ifmt!("{"); //~ ERROR: unterminated format string |
43 |
| - ifmt!("\\ "); //~ ERROR: invalid escape |
44 |
| - ifmt!("\\"); //~ ERROR: expected an escape |
| 42 | + format!("{"); //~ ERROR: unterminated format string |
| 43 | + format!("\\ "); //~ ERROR: invalid escape |
| 44 | + format!("\\"); //~ ERROR: expected an escape |
45 | 45 |
|
46 |
| - ifmt!("{0, }", 1); //~ ERROR: expected method |
47 |
| - ifmt!("{0, foo}", 1); //~ ERROR: unknown method |
48 |
| - ifmt!("{0, select}", "a"); //~ ERROR: must be followed by |
49 |
| - ifmt!("{0, plural}", 1); //~ ERROR: must be followed by |
| 46 | + format!("{0, }", 1); //~ ERROR: expected method |
| 47 | + format!("{0, foo}", 1); //~ ERROR: unknown method |
| 48 | + format!("{0, select}", "a"); //~ ERROR: must be followed by |
| 49 | + format!("{0, plural}", 1); //~ ERROR: must be followed by |
50 | 50 |
|
51 |
| - ifmt!("{0, select, a{{}", 1); //~ ERROR: must be terminated |
52 |
| - ifmt!("{0, select, {} other{}}", "a"); //~ ERROR: empty selector |
53 |
| - ifmt!("{0, select, other{} other{}}", "a"); //~ ERROR: multiple `other` |
54 |
| - ifmt!("{0, plural, offset: other{}}", "a"); //~ ERROR: must be an integer |
55 |
| - ifmt!("{0, plural, offset 1 other{}}", "a"); //~ ERROR: be followed by `:` |
56 |
| - ifmt!("{0, plural, =a{} other{}}", "a"); //~ ERROR: followed by an integer |
57 |
| - ifmt!("{0, plural, a{} other{}}", "a"); //~ ERROR: unexpected plural |
58 |
| - ifmt!("{0, select, a{}}", "a"); //~ ERROR: must provide an `other` |
59 |
| - ifmt!("{0, plural, =1{}}", "a"); //~ ERROR: must provide an `other` |
| 51 | + format!("{0, select, a{{}", 1); //~ ERROR: must be terminated |
| 52 | + format!("{0, select, {} other{}}", "a"); //~ ERROR: empty selector |
| 53 | + format!("{0, select, other{} other{}}", "a"); //~ ERROR: multiple `other` |
| 54 | + format!("{0, plural, offset: other{}}", "a"); //~ ERROR: must be an integer |
| 55 | + format!("{0, plural, offset 1 other{}}", "a"); //~ ERROR: be followed by `:` |
| 56 | + format!("{0, plural, =a{} other{}}", "a"); //~ ERROR: followed by an integer |
| 57 | + format!("{0, plural, a{} other{}}", "a"); //~ ERROR: unexpected plural |
| 58 | + format!("{0, select, a{}}", "a"); //~ ERROR: must provide an `other` |
| 59 | + format!("{0, plural, =1{}}", "a"); //~ ERROR: must provide an `other` |
60 | 60 |
|
61 |
| - ifmt!("{0, plural, other{{0:s}}}", "a"); //~ ERROR: previously used as |
62 |
| - ifmt!("{:s} {0, plural, other{}}", "a"); //~ ERROR: argument used to |
63 |
| - ifmt!("{0, select, other{}} \ |
64 |
| - {0, plural, other{}}", "a"); |
| 61 | + format!("{0, plural, other{{0:s}}}", "a"); //~ ERROR: previously used as |
| 62 | + format!("{:s} {0, plural, other{}}", "a"); //~ ERROR: argument used to |
| 63 | + format!("{0, select, other{}} \ |
| 64 | + {0, plural, other{}}", "a"); |
65 | 65 | //~^ ERROR: declared with multiple formats
|
66 | 66 |
|
67 | 67 | // It should be illegal to use implicit placement arguments nested inside of
|
68 | 68 | // format strings because otherwise the "internal pointer of which argument
|
69 | 69 | // is next" would be invalidated if different cases had different numbers of
|
70 | 70 | // arguments.
|
71 |
| - ifmt!("{0, select, other{{}}}", "a"); //~ ERROR: cannot use implicit |
72 |
| - ifmt!("{0, plural, other{{}}}", 1); //~ ERROR: cannot use implicit |
73 |
| - ifmt!("{0, plural, other{{1:.*d}}}", 1, 2); //~ ERROR: cannot use implicit |
| 71 | + format!("{0, select, other{{}}}", "a"); //~ ERROR: cannot use implicit |
| 72 | + format!("{0, plural, other{{}}}", 1); //~ ERROR: cannot use implicit |
| 73 | + format!("{0, plural, other{{1:.*d}}}", 1, 2); //~ ERROR: cannot use implicit |
74 | 74 | }
|
0 commit comments