rust/src/libsyntax_ext
Mazdak Farrokhzad edc846f29e
Rollup merge of #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 #49384.
2019-08-03 00:09:06 +02:00
..
deriving Remove derives Encodable/Decodable and unstabilize attribute #[bench] 2019-07-31 21:27:59 +03:00
format_foreign Separate libsyntax_ext module 2019-06-16 14:17:01 +03:00
asm.rs syntax: Migrate built-in macros to the regular stability checking 2019-07-07 13:04:07 +03:00
assert.rs Adjust other names after the Mark renaming 2019-07-19 12:01:49 +03:00
Cargo.toml Move test harness generation into libsyntax_ext 2019-07-27 13:56:54 +03:00
cfg.rs Adjust other names after the Mark renaming 2019-07-19 12:01:49 +03:00
compile_error.rs libsyntax_ext => 2018 2019-02-04 21:49:54 +09:00
concat.rs Adjust other names after the Mark renaming 2019-07-19 12:01:49 +03:00
concat_idents.rs Adjust other names after the Mark renaming 2019-07-19 12:01:49 +03:00
env.rs Adjust other names after the Mark renaming 2019-07-19 12:01:49 +03:00
error_codes.rs Remove lint annotations in specific crates that are already enforced by rustbuild 2019-07-28 18:46:24 +03:00
format.rs fix dedup 2019-07-31 14:13:00 -07:00
format_foreign.rs Separate libsyntax_ext module 2019-06-16 14:17:01 +03:00
global_allocator.rs Fix rebase 2019-07-24 12:29:45 +03:00
global_asm.rs syntax: Migrate built-in macros to the regular stability checking 2019-07-07 13:04:07 +03:00
lib.rs Remove derives Encodable/Decodable and unstabilize attribute #[bench] 2019-07-31 21:27:59 +03:00
log_syntax.rs syntax: Migrate built-in macros to the regular stability checking 2019-07-07 13:04:07 +03:00
plugin_macro_defs.rs Introduce built-in macros through libcore 2019-07-26 13:09:54 +03:00
proc_macro_harness.rs syntax_ext: proc_macro_decls -> proc_macro_harness 2019-07-27 14:16:16 +03:00
source_util.rs Break dependencies between syntax_ext and some other crates 2019-07-27 13:52:37 +03:00
standard_library_imports.rs Move standard library injection into libsyntax_ext 2019-07-27 13:56:54 +03:00
test.rs syntax_ext: proc_macro_decls -> proc_macro_harness 2019-07-27 14:16:16 +03:00
test_harness.rs syntax_ext: proc_macro_decls -> proc_macro_harness 2019-07-27 14:16:16 +03:00
trace_macros.rs syntax: Migrate built-in macros to the regular stability checking 2019-07-07 13:04:07 +03:00