Commit edc846f
authored
Rollup merge of rust-lang#63121 - estebank:formatting-pos, r=alexcrichton
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: invalid reference to positional argument 7 (there are 3 arguments)
--> $DIR/ifmt-bad-arg.rs:84:18
|
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
```
Fix rust-lang#49384.File tree
7 files changed
+463
-195
lines changed- src
- libfmt_macros
- libsyntax_ext
- libsyntax_pos
- test/ui/if
7 files changed
+463
-195
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| |||
282 | 286 | | |
283 | 287 | | |
284 | 288 | | |
285 | | - | |
286 | | - | |
| 289 | + | |
| 290 | + | |
287 | 291 | | |
288 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
289 | 301 | | |
290 | 302 | | |
291 | | - | |
292 | | - | |
293 | | - | |
| 303 | + | |
294 | 304 | | |
295 | | - | |
296 | | - | |
297 | 305 | | |
| 306 | + | |
298 | 307 | | |
299 | 308 | | |
300 | 309 | | |
| |||
462 | 471 | | |
463 | 472 | | |
464 | 473 | | |
| 474 | + | |
465 | 475 | | |
| 476 | + | |
466 | 477 | | |
467 | 478 | | |
468 | 479 | | |
| |||
499 | 510 | | |
500 | 511 | | |
501 | 512 | | |
| 513 | + | |
502 | 514 | | |
503 | 515 | | |
504 | 516 | | |
| |||
512 | 524 | | |
513 | 525 | | |
514 | 526 | | |
515 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
516 | 535 | | |
517 | | - | |
518 | | - | |
| 536 | + | |
| 537 | + | |
519 | 538 | | |
520 | 539 | | |
521 | 540 | | |
522 | 541 | | |
523 | 542 | | |
| 543 | + | |
| 544 | + | |
524 | 545 | | |
525 | | - | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
526 | 549 | | |
527 | 550 | | |
528 | 551 | | |
| |||
551 | 574 | | |
552 | 575 | | |
553 | 576 | | |
554 | | - | |
| 577 | + | |
555 | 578 | | |
556 | | - | |
557 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
558 | 582 | | |
559 | | - | |
| 583 | + | |
560 | 584 | | |
561 | 585 | | |
562 | 586 | | |
563 | 587 | | |
564 | 588 | | |
565 | 589 | | |
566 | | - | |
| 590 | + | |
567 | 591 | | |
568 | | - | |
| 592 | + | |
569 | 593 | | |
570 | 594 | | |
571 | | - | |
| 595 | + | |
572 | 596 | | |
573 | 597 | | |
574 | 598 | | |
| |||
0 commit comments