2018-07-23 05:40:24 +00:00
error: 1 positional argument in format string, but no arguments were given
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:6:14
2018-07-23 05:40:24 +00:00
|
LL | format!("{}");
| ^^
error: invalid reference to positional argument 1 (there is 1 argument)
2022-08-26 16:52:08 +00:00
--> $DIR/ifmt-bad-arg.rs:9:15
2018-07-23 05:40:24 +00:00
|
LL | format!("{1}", 1);
2022-08-26 16:52:08 +00:00
| ^
2018-07-23 05:40:24 +00:00
|
= note: positional arguments are zero-based
error: argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:9:20
2018-07-23 05:40:24 +00:00
|
LL | format!("{1}", 1);
2018-12-27 04:18:41 +00:00
| ----- ^ argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: 2 positional arguments in format string, but no arguments were given
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:13:14
2018-07-23 05:40:24 +00:00
|
LL | format!("{} {}");
| ^^ ^^
error: invalid reference to positional argument 1 (there is 1 argument)
2022-08-26 16:52:08 +00:00
--> $DIR/ifmt-bad-arg.rs:16:19
2018-07-23 05:40:24 +00:00
|
LL | format!("{0} {1}", 1);
2022-08-26 16:52:08 +00:00
| ^
2018-07-23 05:40:24 +00:00
|
= note: positional arguments are zero-based
error: invalid reference to positional argument 2 (there are 2 arguments)
2022-08-26 16:52:08 +00:00
--> $DIR/ifmt-bad-arg.rs:19:23
2018-07-23 05:40:24 +00:00
|
LL | format!("{0} {1} {2}", 1, 2);
2022-08-26 16:52:08 +00:00
| ^
2018-07-23 05:40:24 +00:00
|
= note: positional arguments are zero-based
2022-08-26 16:52:08 +00:00
error: 3 positional arguments in format string, but there are 2 arguments
--> $DIR/ifmt-bad-arg.rs:22:14
2018-07-23 05:40:24 +00:00
|
LL | format!("{} {value} {} {}", 1, value=2);
2022-08-26 16:52:08 +00:00
| ^^ ^^ ^^ - -
2018-07-23 05:40:24 +00:00
2022-08-26 16:52:08 +00:00
error: 6 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:24:29
2018-07-23 05:40:24 +00:00
|
LL | format!("{name} {value} {} {} {} {} {} {}", 0, name=1, value=2);
2022-08-26 16:52:08 +00:00
| ^^ ^^ ^^ ^^ ^^ ^^ - - -
2018-07-23 05:40:24 +00:00
error: multiple unused formatting arguments
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:32:17
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("", 1, 2);
2018-12-27 04:18:41 +00:00
| -- ^ ^ argument never used
| | |
| | argument never used
2018-07-24 16:51:04 +00:00
| multiple missing formatting specifiers
2018-07-23 05:40:24 +00:00
error: argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:33:22
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{}", 1, 2);
2018-12-27 04:18:41 +00:00
| ---- ^ argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:34:20
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{1}", 1, 2);
2018-12-27 04:18:41 +00:00
| ----- ^ argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: named argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:35:26
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{}", 1, foo=2);
2018-12-27 04:18:41 +00:00
| ---- ^ named argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:36:22
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{foo}", 1, foo=2);
2018-12-27 04:18:41 +00:00
| ------- ^ argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: named argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:37:21
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("", foo=2);
2018-12-27 04:18:41 +00:00
| -- ^ named argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: multiple unused formatting arguments
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:38:32
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{} {}", 1, 2, foo=1, bar=2);
2018-12-27 04:18:41 +00:00
| ------- ^ ^ named argument never used
| | |
| | named argument never used
2018-07-24 16:51:04 +00:00
| multiple missing formatting specifiers
2018-07-23 05:40:24 +00:00
error: duplicate argument named `foo`
2022-08-08 14:17:08 +00:00
--> $DIR/ifmt-bad-arg.rs:40:29
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{foo}", foo=1, foo=2);
2022-08-08 14:17:08 +00:00
| --- ^^^ duplicate argument
| |
| previously here
2018-07-23 05:40:24 +00:00
2019-07-16 03:51:32 +00:00
error: positional arguments cannot follow named arguments
--> $DIR/ifmt-bad-arg.rs:41:35
2018-07-23 05:40:24 +00:00
|
2019-07-16 03:51:32 +00:00
LL | format!("{foo} {} {}", foo=1, 2);
2022-08-08 14:17:08 +00:00
| ----- ^ positional arguments must be before named arguments
| |
| named argument
2018-07-23 05:40:24 +00:00
error: named argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:45:51
2018-07-23 05:40:24 +00:00
|
LL | format!("{valuea} {valueb}", valuea=5, valuec=7);
2018-12-27 04:18:41 +00:00
| ------------------- ^ named argument never used
2018-07-25 03:46:22 +00:00
| |
| formatting specifier missing
2018-07-23 05:40:24 +00:00
error: invalid format string: expected `'}'` but string was terminated
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:51:15
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("{");
2018-12-21 06:33:16 +00:00
| -^ expected `'}'` in format string
| |
| because of this opening brace
2018-07-23 05:40:24 +00:00
|
= note: if you intended to print `{`, you can escape it using `{{`
error: invalid format string: unmatched `}` found
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:53:18
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("foo } bar");
2018-07-23 05:40:24 +00:00
| ^ unmatched `}` in format string
|
= note: if you intended to print `}`, you can escape it using `}}`
error: invalid format string: unmatched `}` found
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:54:18
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("foo }");
2018-07-23 05:40:24 +00:00
| ^ unmatched `}` in format string
|
= note: if you intended to print `}`, you can escape it using `}}`
error: argument never used
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:56:27
2018-07-23 05:40:24 +00:00
|
2019-03-09 12:03:44 +00:00
LL | format!("foo %s baz", "bar");
2018-12-27 04:18:41 +00:00
| -- ^^^^^ argument never used
2018-07-24 23:01:38 +00:00
| |
2018-07-25 03:46:22 +00:00
| help: format specifiers use curly braces: `{}`
2018-07-23 05:40:24 +00:00
|
2023-01-02 11:23:43 +00:00
= note: printf formatting is not supported; see the documentation for `std::fmt`
2018-07-23 05:40:24 +00:00
2018-10-03 18:29:02 +00:00
error: invalid format string: expected `'}'`, found `'t'`
2018-12-25 15:56:47 +00:00
--> $DIR/ifmt-bad-arg.rs:75:1
2018-10-03 18:29:02 +00:00
|
2018-12-21 06:33:16 +00:00
LL | ninth number: {
| - because of this opening brace
2018-10-03 18:29:02 +00:00
LL | tenth number: {}",
2023-07-17 00:32:13 +00:00
| ^ expected `'}'` in format string
2018-12-21 06:33:16 +00:00
|
= note: if you intended to print `{`, you can escape it using `{{`
2018-10-03 18:29:02 +00:00
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
2019-10-24 00:32:33 +00:00
| ^^ ^^--^ ^^ - --- -
2022-08-26 16:52:08 +00:00
| |
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2022-08-26 16:52:08 +00:00
error: invalid reference to positional arguments 3 and 7 (there are 3 arguments)
--> $DIR/ifmt-bad-arg.rs:81:21
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
2022-08-26 16:52:08 +00:00
| ^^ ^
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2019-07-30 04:24:10 +00:00
error: invalid reference to positional argument 7 (there are 3 arguments)
2022-08-26 16:52:08 +00:00
--> $DIR/ifmt-bad-arg.rs:84:21
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
2022-08-26 16:52:08 +00:00
| ^^
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2019-07-30 04:24:10 +00:00
error: unknown format trait `foo`
Point at formatting descriptor string when it is invalid
When a formatting string contains an invalid descriptor, point at it
instead of the argument:
```
error: unknown format trait `foo`
--> $DIR/ifmt-bad-arg.rs:86:17
|
LL | println!("{:foo}", 1);
| ^^^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
```
2019-11-05 19:55:00 +00:00
--> $DIR/ifmt-bad-arg.rs:86:17
2019-07-30 04:24:10 +00:00
|
LL | println!("{:foo}", 1);
Point at formatting descriptor string when it is invalid
When a formatting string contains an invalid descriptor, point at it
instead of the argument:
```
error: unknown format trait `foo`
--> $DIR/ifmt-bad-arg.rs:86:17
|
LL | println!("{:foo}", 1);
| ^^^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
```
2019-11-05 19:55:00 +00:00
| ^^^
2019-07-30 04:24:10 +00:00
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: invalid reference to positional arguments 4, 5, 6 and 7 (there is 1 argument)
2022-08-26 16:52:08 +00:00
--> $DIR/ifmt-bad-arg.rs:87:16
2019-07-30 04:24:10 +00:00
|
LL | println!("{5} {:4$} {6:7$}", 1);
2022-08-26 16:52:08 +00:00
| ^ ^^ ^ ^^
2019-07-30 04:24:10 +00:00
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2022-07-20 12:40:45 +00:00
error: invalid reference to positional argument 0 (no arguments were given)
2022-08-26 16:52:08 +00:00
--> $DIR/ifmt-bad-arg.rs:90:20
2022-07-20 12:40:45 +00:00
|
LL | println!("{foo:0$}");
2022-08-26 16:52:08 +00:00
| ^^
2022-07-20 12:40:45 +00:00
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2019-11-04 18:57:41 +00:00
error: 2 positional arguments in format string, but no arguments were given
2022-07-20 12:40:45 +00:00
--> $DIR/ifmt-bad-arg.rs:95:15
2019-11-04 18:57:41 +00:00
|
LL | println!("{:.*}");
| ^^--^
| |
| this precision flag adds an extra required argument at position 0, which is why there are 2 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2022-09-06 21:08:27 +00:00
error: invalid reference to positional argument 0 (no arguments were given)
--> $DIR/ifmt-bad-arg.rs:97:16
2022-08-25 12:49:42 +00:00
|
LL | println!("{:.0$}");
2022-09-06 21:08:27 +00:00
| ^^^^
2022-08-25 12:49:42 +00:00
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
2021-11-01 16:51:54 +00:00
error[E0425]: cannot find value `foo` in this scope
2022-02-16 00:38:04 +00:00
--> $DIR/ifmt-bad-arg.rs:27:18
2021-11-01 16:51:54 +00:00
|
LL | format!("{} {foo} {} {bar} {}", 1, 2, 3);
2022-02-16 00:38:04 +00:00
| ^^^ not found in this scope
2021-11-01 16:51:54 +00:00
error[E0425]: cannot find value `bar` in this scope
2022-02-16 00:38:04 +00:00
--> $DIR/ifmt-bad-arg.rs:27:27
2021-11-01 16:51:54 +00:00
|
LL | format!("{} {foo} {} {bar} {}", 1, 2, 3);
2022-02-16 00:38:04 +00:00
| ^^^ not found in this scope
2021-11-01 16:51:54 +00:00
error[E0425]: cannot find value `foo` in this scope
2022-02-16 00:38:04 +00:00
--> $DIR/ifmt-bad-arg.rs:31:15
2021-11-01 16:51:54 +00:00
|
LL | format!("{foo}");
2022-02-16 00:38:04 +00:00
| ^^^ not found in this scope
2021-11-01 16:51:54 +00:00
error[E0425]: cannot find value `valueb` in this scope
2022-02-16 00:38:04 +00:00
--> $DIR/ifmt-bad-arg.rs:45:24
2021-11-01 16:51:54 +00:00
|
LL | format!("{valuea} {valueb}", valuea=5, valuec=7);
2022-02-16 00:38:04 +00:00
| ^^^^^^ not found in this scope
2021-11-01 16:51:54 +00:00
error[E0425]: cannot find value `foo` in this scope
2022-02-16 00:38:04 +00:00
--> $DIR/ifmt-bad-arg.rs:60:10
2021-11-01 16:51:54 +00:00
|
LL | {foo}
2022-02-16 00:38:04 +00:00
| ^^^ not found in this scope
2021-11-01 16:51:54 +00:00
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
error[E0308]: mismatched types
--> $DIR/ifmt-bad-arg.rs:78:32
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
2023-03-27 12:43:17 +00:00
| -- ^^^ expected `&usize`, found `&{float}`
| |
| arguments to this function are incorrect
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
|
2019-11-13 22:16:56 +00:00
= note: expected reference `&usize`
found reference `&{float}`
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.
The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.
We then modify that algorithm to detect 4 cases:
- A function input is missing
- An extra argument was provided
- The type of an argument is straight up invalid
- Two arguments have been swapped
- A subset of the arguments have been shuffled
(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)
It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.
The basic sketch of the algorithm is as follows:
- Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input.
- If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
- Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
- Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
- Swapped / Permuted arguments are identified with a cycle detection algorithm.
As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again.
Note that there's a lot of extra complexity:
- We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
- Closure arguments are wrapped in a tuple and need to be unwrapped
- We need to resolve closure types after the rest, to allow the most specific type constraints
- We need to handle imported C functions that might be variadic in their inputs.
I tried to document a lot of this in comments in the code and keep the naming clear.
2022-01-22 04:50:54 +00:00
note: associated function defined here
2023-04-20 18:18:22 +00:00
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
2022-06-21 02:25:52 +00:00
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
error[E0308]: mismatched types
--> $DIR/ifmt-bad-arg.rs:81:35
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
2023-03-27 12:43:17 +00:00
| -- ^^^ expected `&usize`, found `&{float}`
| |
| arguments to this function are incorrect
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
|
2019-11-13 22:16:56 +00:00
= note: expected reference `&usize`
found reference `&{float}`
Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.
The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.
We then modify that algorithm to detect 4 cases:
- A function input is missing
- An extra argument was provided
- The type of an argument is straight up invalid
- Two arguments have been swapped
- A subset of the arguments have been shuffled
(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)
It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.
The basic sketch of the algorithm is as follows:
- Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input.
- If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
- Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
- Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
- Swapped / Permuted arguments are identified with a cycle detection algorithm.
As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again.
Note that there's a lot of extra complexity:
- We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
- Closure arguments are wrapped in a tuple and need to be unwrapped
- We need to resolve closure types after the rest, to allow the most specific type constraints
- We need to handle imported C functions that might be variadic in their inputs.
I tried to document a lot of this in comments in the code and keep the naming clear.
2022-01-22 04:50:54 +00:00
note: associated function defined here
2023-04-20 18:18:22 +00:00
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
2022-06-21 02:25:52 +00:00
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
On `format!()` arg count mismatch provide extra info
When positional width and precision formatting flags are present in a
formatting string that has an argument count mismatch, provide extra
information pointing at them making it easiser to understand where the
problem may lay:
```
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:78:15
|
LL | println!("{} {:.*} {}", 1, 3.2, 4);
| ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag
| |
| this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 4 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
| | |
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
error: 3 positional arguments in format string, but there are 3 arguments
--> $DIR/ifmt-bad-arg.rs:84:15
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
| ^^ ^^---^ ^^
| |
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
```
2019-07-30 01:19:21 +00:00
2022-08-25 12:49:42 +00:00
error: aborting due to 38 previous errors
2018-07-23 05:40:24 +00:00
2021-11-01 16:51:54 +00:00
Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.