Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On `format!()` arg count mismatch provide extra info #63121

Merged
merged 5 commits into from Aug 3, 2019

Conversation

@estebank
Copy link
Contributor

commented Jul 30, 2019

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.

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
```
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 30, 2019

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@estebank

This comment has been minimized.

Copy link
Contributor Author

commented Jul 30, 2019

src/libfmt_macros/lib.rs Show resolved Hide resolved
src/libfmt_macros/lib.rs Show resolved Hide resolved
src/libsyntax_ext/format.rs Outdated Show resolved Hide resolved
src/libfmt_macros/lib.rs Outdated Show resolved Hide resolved
@Centril

This comment has been minimized.

Copy link
Member

commented Jul 30, 2019

Unfortunately I'm not really familiar with this part of the compiler so I don't feel comfortable doing the main review but I left some comments above.

r? @alexcrichton cc @Mark-Simulacrum

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Jul 30, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-07-30T01:23:36.9276500Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-30T01:23:36.9499835Z ##[command]git config gc.auto 0
2019-07-30T01:23:36.9621557Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-30T01:23:36.9682079Z ##[command]git config --get-all http.proxy
2019-07-30T01:23:36.9821392Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63121/merge:refs/remotes/pull/63121/merge
---
2019-07-30T01:24:11.4137339Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-30T01:24:11.4137374Z 
2019-07-30T01:24:11.4137806Z   git checkout -b <new-branch-name>
2019-07-30T01:24:11.4137837Z 
2019-07-30T01:24:11.4137905Z HEAD is now at 7765f4bbe Merge 159dcb2194e6af28e070f15b9a69af354f87d6d6 into 04b88a9eba8abbac87eddcb2998beea09589c2c9
2019-07-30T01:24:11.4286058Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-30T01:24:11.4288599Z ==============================================================================
2019-07-30T01:24:11.4288652Z Task         : Bash
2019-07-30T01:24:11.4288713Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-30T02:25:09.3727962Z .................................................................................................... 1400/8804
2019-07-30T02:25:15.5070221Z .................................................................................................... 1500/8804
2019-07-30T02:25:28.3839082Z ................................................................i...............i................... 1600/8804
2019-07-30T02:25:36.1513166Z .................................................................................................... 1700/8804
2019-07-30T02:25:51.2652567Z ..................................................iiiii............................................. 1800/8804
2019-07-30T02:26:02.6790700Z .................................................................................................... 2000/8804
2019-07-30T02:26:05.3324769Z .................................................................................................... 2100/8804
2019-07-30T02:26:09.4260797Z .................................................................................................... 2200/8804
2019-07-30T02:26:16.1406865Z .................................................................................................... 2300/8804
---
2019-07-30T02:30:06.5617103Z .................................................................................................... 5200/8804
2019-07-30T02:30:17.5514330Z .................................................................................................... 5300/8804
2019-07-30T02:30:25.2182531Z ..i................................................................................................. 5400/8804
2019-07-30T02:30:30.7025373Z .................................................................................................... 5500/8804
2019-07-30T02:30:43.2379321Z ................................................................................................ii.. 5600/8804
2019-07-30T02:30:58.0923660Z .i..ii............i................................................................................. 5700/8804
2019-07-30T02:31:13.1636559Z .................................................................................................... 5900/8804
2019-07-30T02:31:17.9730665Z ................................................................................................i..i 6000/8804
2019-07-30T02:31:32.4744081Z i................................................................................................... 6100/8804
2019-07-30T02:31:48.9492051Z .................................................................................................... 6200/8804
---
2019-07-30T02:36:47.5367711Z  finished in 23.595
2019-07-30T02:36:47.5545498Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T02:36:47.7136045Z 
2019-07-30T02:36:47.7136164Z running 146 tests
2019-07-30T02:36:51.0136373Z i....iii......iii..iiii....i............................i..i................i....i.........ii.i.i..i 100/146
2019-07-30T02:36:52.8992370Z iii..............i.........iii.i......ii......
2019-07-30T02:36:52.8992906Z 
2019-07-30T02:36:52.8992969Z  finished in 5.343
2019-07-30T02:36:52.9184811Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T02:36:53.0764964Z 
---
2019-07-30T02:36:55.1638451Z  finished in 2.245
2019-07-30T02:36:55.1828237Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T02:36:55.3408023Z 
2019-07-30T02:36:55.3408668Z running 9 tests
2019-07-30T02:36:55.3411506Z iiiiiiiii
2019-07-30T02:36:55.3413882Z 
2019-07-30T02:36:55.3414207Z  finished in 0.158
2019-07-30T02:36:55.3597277Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T02:36:55.5228856Z 
---
2019-07-30T02:37:14.4330428Z  finished in 19.073
2019-07-30T02:37:14.4522502Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T02:37:14.6185662Z 
2019-07-30T02:37:14.6186070Z running 122 tests
2019-07-30T02:37:39.5488548Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....i..........iiii..........i...ii...i.......ii.i 100/122
2019-07-30T02:37:44.5361893Z .i.i......iii.i.....ii
2019-07-30T02:37:44.5362352Z 
2019-07-30T02:37:44.5363340Z  finished in 30.083
2019-07-30T02:37:44.5369617Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T02:37:44.5369887Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-07-30T02:51:57.1472421Z 
2019-07-30T02:51:57.1482654Z    Doc-tests core
2019-07-30T02:52:01.3586367Z 
2019-07-30T02:52:01.3587576Z running 2379 tests
2019-07-30T02:52:13.9747436Z ......iiiii......................................................................................... 100/2379
2019-07-30T02:52:26.7730215Z .........................................................................ii......................... 200/2379
2019-07-30T02:52:56.6799916Z .................................................................................................... 400/2379
2019-07-30T02:52:56.6799916Z .................................................................................................... 400/2379
2019-07-30T02:53:08.1505115Z ..............................i..i.................iiii............................................. 500/2379
2019-07-30T02:53:32.1991407Z .................................................................................................... 700/2379
2019-07-30T02:53:44.3267676Z .................................................................................................... 800/2379
2019-07-30T02:53:56.4806229Z .................................................................................................... 900/2379
2019-07-30T02:54:08.6527160Z .................................................................................................... 1000/2379
---
2019-07-30T02:59:27.8663465Z 
2019-07-30T02:59:27.8664991Z running 989 tests
2019-07-30T02:59:52.2047901Z i................................................................................................... 100/989
2019-07-30T03:00:05.8816688Z .................................................................................................... 200/989
2019-07-30T03:00:15.0175512Z .................iii......i......i...i......i....................................................... 300/989
2019-07-30T03:00:20.2588172Z .................................................................................................... 400/989
2019-07-30T03:00:28.4406905Z ................................i..i.................................ii............................. 500/989
2019-07-30T03:00:43.9416069Z .................................................................................................... 700/989
2019-07-30T03:00:43.9416069Z .................................................................................................... 700/989
2019-07-30T03:00:52.7644158Z ...............iiii................................................................................. 800/989
2019-07-30T03:01:07.4892574Z .................................................................................................... 900/989
2019-07-30T03:01:15.3162413Z .....................................iiii................................................
2019-07-30T03:01:15.3164528Z 
2019-07-30T03:01:15.3369758Z  finished in 246.658
2019-07-30T03:01:15.3383251Z Testing unwind stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T03:01:15.5261451Z     Finished release [optimized] target(s) in 0.18s
---
2019-07-30T03:01:17.5085284Z 
2019-07-30T03:01:17.5141701Z  finished in 1.926
2019-07-30T03:01:17.5160435Z Testing fmt_macros stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T03:01:17.7341439Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2019-07-30T03:01:17.9071338Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9071646Z  --> src/libfmt_macros/tests.rs:9:12
2019-07-30T03:01:17.9072063Z 9 |     return FormatSpec {
2019-07-30T03:01:17.9072063Z 9 |     return FormatSpec {
2019-07-30T03:01:17.9072338Z   |            ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9072374Z 
2019-07-30T03:01:17.9105863Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9106167Z   --> src/libfmt_macros/tests.rs:85:24
2019-07-30T03:01:17.9106395Z    |
2019-07-30T03:01:17.9106695Z 85 |                format: FormatSpec {
2019-07-30T03:01:17.9107034Z    |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9107082Z 
2019-07-30T03:01:17.9115949Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9116289Z    --> src/libfmt_macros/tests.rs:100:24
2019-07-30T03:01:17.9116563Z     |
2019-07-30T03:01:17.9116885Z 100 |                format: FormatSpec {
2019-07-30T03:01:17.9117259Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9117333Z 
2019-07-30T03:01:17.9117810Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9118041Z    --> src/libfmt_macros/tests.rs:112:24
2019-07-30T03:01:17.9118245Z     |
2019-07-30T03:01:17.9118489Z 112 |                format: FormatSpec {
2019-07-30T03:01:17.9118783Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9118835Z 
2019-07-30T03:01:17.9119255Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9119619Z    --> src/libfmt_macros/tests.rs:124:24
2019-07-30T03:01:17.9119823Z     |
2019-07-30T03:01:17.9120067Z 124 |                format: FormatSpec {
2019-07-30T03:01:17.9120363Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9120414Z 
2019-07-30T03:01:17.9124581Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9124867Z    --> src/libfmt_macros/tests.rs:141:24
2019-07-30T03:01:17.9125102Z     |
2019-07-30T03:01:17.9125392Z 141 |                format: FormatSpec {
2019-07-30T03:01:17.9125733Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9125801Z 
2019-07-30T03:01:17.9139225Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9139509Z    --> src/libfmt_macros/tests.rs:153:24
2019-07-30T03:01:17.9139735Z     |
2019-07-30T03:01:17.9139985Z 153 |                format: FormatSpec {
2019-07-30T03:01:17.9140290Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9140361Z 
2019-07-30T03:01:17.9140630Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9140869Z    --> src/libfmt_macros/tests.rs:165:24
2019-07-30T03:01:17.9141073Z     |
2019-07-30T03:01:17.9141316Z 165 |                format: FormatSpec {
2019-07-30T03:01:17.9141783Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9141836Z 
2019-07-30T03:01:17.9142260Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9142474Z    --> src/libfmt_macros/tests.rs:177:24
2019-07-30T03:01:17.9144164Z     |
2019-07-30T03:01:17.9144735Z 177 |                format: FormatSpec {
2019-07-30T03:01:17.9145076Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9145129Z 
2019-07-30T03:01:17.9155273Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9155618Z    --> src/libfmt_macros/tests.rs:189:24
2019-07-30T03:01:17.9155887Z     |
2019-07-30T03:01:17.9156190Z 189 |                format: FormatSpec {
2019-07-30T03:01:17.9156559Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9156779Z 
2019-07-30T03:01:17.9161673Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9162204Z    --> src/libfmt_macros/tests.rs:205:24
2019-07-30T03:01:17.9162469Z     |
2019-07-30T03:01:17.9165617Z 205 |                format: FormatSpec {
2019-07-30T03:01:17.9167244Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9167299Z 
2019-07-30T03:01:17.9179343Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9192371Z    --> src/libfmt_macros/tests.rs:217:24
2019-07-30T03:01:17.9194229Z     |
2019-07-30T03:01:17.9194632Z 217 |                format: FormatSpec {
2019-07-30T03:01:17.9194975Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9195030Z 
2019-07-30T03:01:17.9195994Z error[E0063]: missing fields `precision_span`, `width_span` in initializer of `FormatSpec<'_>`
2019-07-30T03:01:17.9196260Z    --> src/libfmt_macros/tests.rs:233:24
2019-07-30T03:01:17.9196493Z     |
2019-07-30T03:01:17.9196767Z 233 |                format: FormatSpec {
2019-07-30T03:01:17.9197113Z     |                        ^^^^^^^^^^ missing `precision_span`, `width_span`
2019-07-30T03:01:17.9197737Z error: aborting due to 13 previous errors
2019-07-30T03:01:17.9197768Z 
2019-07-30T03:01:17.9198336Z For more information about this error, try `rustc --explain E0063`.
2019-07-30T03:01:17.9336737Z error: Could not compile `fmt_macros`.
2019-07-30T03:01:17.9336737Z error: Could not compile `fmt_macros`.
2019-07-30T03:01:17.9338739Z 
2019-07-30T03:01:17.9339125Z To learn more, run the command again with --verbose.
2019-07-30T03:01:17.9355290Z 
2019-07-30T03:01:17.9355409Z 
2019-07-30T03:01:17.9356152Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--locked" "--color" "always" "--features" "" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "-p" "fmt_macros" "--" "--quiet"
2019-07-30T03:01:17.9356299Z 
2019-07-30T03:01:17.9356325Z 
2019-07-30T03:01:17.9366199Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-30T03:01:17.9366275Z Build completed unsuccessfully in 1:31:00
2019-07-30T03:01:17.9366275Z Build completed unsuccessfully in 1:31:00
2019-07-30T03:01:18.8152138Z ##[error]Bash exited with code '1'.
2019-07-30T03:01:18.8191620Z ##[section]Starting: Checkout
2019-07-30T03:01:18.8193163Z ==============================================================================
2019-07-30T03:01:18.8193207Z Task         : Get sources
2019-07-30T03:01:18.8193247Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Jul 30, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-07-30T04:52:11.8645480Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-30T04:52:11.8876496Z ##[command]git config gc.auto 0
2019-07-30T04:52:11.8923998Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-30T04:52:11.8972615Z ##[command]git config --get-all http.proxy
2019-07-30T04:52:11.9109020Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63121/merge:refs/remotes/pull/63121/merge
---
2019-07-30T04:52:47.2935193Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-30T04:52:47.2935227Z 
2019-07-30T04:52:47.2935460Z   git checkout -b <new-branch-name>
2019-07-30T04:52:47.2935697Z 
2019-07-30T04:52:47.2935774Z HEAD is now at 89b1dd877 Merge 757c2fd516423424fb06e5ae6e7d996cdf4051b4 into 04b88a9eba8abbac87eddcb2998beea09589c2c9
2019-07-30T04:52:47.3080438Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-30T04:52:47.3083500Z ==============================================================================
2019-07-30T04:52:47.3083569Z Task         : Bash
2019-07-30T04:52:47.3083624Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-30T05:52:09.6182576Z .................................................................................................... 1400/8804
2019-07-30T05:52:15.4585445Z .................................................................................................... 1500/8804
2019-07-30T05:52:27.7313920Z ................................................................i...............i................... 1600/8804
2019-07-30T05:52:35.2853429Z .................................................................................................... 1700/8804
2019-07-30T05:52:49.6653048Z ..................................................iiiii............................................. 1800/8804
2019-07-30T05:53:00.7994474Z .................................................................................................... 2000/8804
2019-07-30T05:53:03.4012902Z .................................................................................................... 2100/8804
2019-07-30T05:53:07.2921710Z .................................................................................................... 2200/8804
2019-07-30T05:53:13.8154393Z .................................................................................................... 2300/8804
---
2019-07-30T05:56:55.5198962Z .................................................................................................... 5200/8804
2019-07-30T05:57:06.0697837Z .................................................................................................... 5300/8804
2019-07-30T05:57:13.4455987Z ..i................................................................................................. 5400/8804
2019-07-30T05:57:18.6794900Z .................................................................................................... 5500/8804
2019-07-30T05:57:30.4524910Z ................................................................................................ii.. 5600/8804
2019-07-30T05:57:44.8692684Z .i..ii...........i.................................................................................. 5700/8804
2019-07-30T05:57:59.4976894Z .................................................................................................... 5900/8804
2019-07-30T05:58:04.2090485Z ................................................................................................i..i 6000/8804
2019-07-30T05:58:18.2032337Z i................................................................................................... 6100/8804
2019-07-30T05:58:34.0982935Z .................................................................................................... 6200/8804
---
2019-07-30T06:03:20.4062184Z  finished in 22.246
2019-07-30T06:03:20.4239745Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:03:20.5794205Z 
2019-07-30T06:03:20.5794397Z running 146 tests
2019-07-30T06:03:23.8735042Z i....iii......iii..iiii....i............................i..i................i....i.........ii.i.i..i 100/146
2019-07-30T06:03:25.7405552Z iii..............i.........iii.i......ii......
2019-07-30T06:03:25.7408978Z 
2019-07-30T06:03:25.7409173Z  finished in 5.317
2019-07-30T06:03:25.7593856Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:03:25.9171762Z 
---
2019-07-30T06:03:28.0263320Z  finished in 2.267
2019-07-30T06:03:28.0479904Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:03:28.2054354Z 
2019-07-30T06:03:28.2054508Z running 9 tests
2019-07-30T06:03:28.2055303Z iiiiiiiii
2019-07-30T06:03:28.2055673Z 
2019-07-30T06:03:28.2058620Z  finished in 0.157
2019-07-30T06:03:28.2246078Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:03:28.3867156Z 
---
2019-07-30T06:03:46.8546616Z  finished in 18.629
2019-07-30T06:03:46.8743452Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:03:47.0404088Z 
2019-07-30T06:03:47.0405555Z running 122 tests
2019-07-30T06:04:11.3976245Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....i..........iiii..........i...ii...i.......ii.i 100/122
2019-07-30T06:04:16.1936465Z .i.i......iii.i.....ii
2019-07-30T06:04:16.1936963Z 
2019-07-30T06:04:16.1940695Z  finished in 29.320
2019-07-30T06:04:16.1948530Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:04:16.1948918Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-07-30T06:18:02.2292338Z 
2019-07-30T06:18:02.2300045Z    Doc-tests core
2019-07-30T06:18:06.3869505Z 
2019-07-30T06:18:06.3870257Z running 2379 tests
2019-07-30T06:18:18.8189258Z ......iiiii......................................................................................... 100/2379
2019-07-30T06:18:31.1946631Z .........................................................................ii......................... 200/2379
2019-07-30T06:19:00.5340503Z .................................................................................................... 400/2379
2019-07-30T06:19:00.5340503Z .................................................................................................... 400/2379
2019-07-30T06:19:11.7607406Z ..............................i..i.................iiii............................................. 500/2379
2019-07-30T06:19:35.1412390Z .................................................................................................... 700/2379
2019-07-30T06:19:46.8139334Z .................................................................................................... 800/2379
2019-07-30T06:19:58.6844974Z .................................................................................................... 900/2379
2019-07-30T06:20:10.7125312Z .................................................................................................... 1000/2379
---
2019-07-30T06:25:23.9938015Z 
2019-07-30T06:25:23.9938283Z running 989 tests
2019-07-30T06:25:48.0527618Z i................................................................................................... 100/989
2019-07-30T06:26:02.0370410Z .................................................................................................... 200/989
2019-07-30T06:26:11.3304061Z .................iii......i......i...i......i....................................................... 300/989
2019-07-30T06:26:16.3409504Z .................................................................................................... 400/989
2019-07-30T06:26:24.6965259Z ................................i..i.................................ii............................. 500/989
2019-07-30T06:26:40.1025855Z .................................................................................................... 700/989
2019-07-30T06:26:40.1025855Z .................................................................................................... 700/989
2019-07-30T06:26:48.7664853Z ...............iiii................................................................................. 800/989
2019-07-30T06:27:03.9424514Z .................................................................................................... 900/989
2019-07-30T06:27:11.4820153Z .....................................iiii................................................
2019-07-30T06:27:11.4820988Z 
2019-07-30T06:27:11.5036439Z  finished in 245.095
2019-07-30T06:27:11.5065265Z Testing unwind stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-30T06:27:11.7016186Z     Finished release [optimized] target(s) in 0.19s
---
2019-07-30T06:27:15.5158166Z running 14 tests
2019-07-30T06:27:15.5180926Z .F............
2019-07-30T06:27:15.5181030Z failures:
2019-07-30T06:27:15.5181162Z 
2019-07-30T06:27:15.5181705Z ---- tests::format_counts stdout ----
2019-07-30T06:27:15.5182099Z thread 'tests::format_counts' panicked at 'assertion failed: parser.collect::<Vec<Piece<'static>>>() == p', src/libfmt_macros/tests.rs:5:5
2019-07-30T06:27:15.5182263Z 
2019-07-30T06:27:15.5182290Z 
2019-07-30T06:27:15.5182330Z failures:
2019-07-30T06:27:15.5182401Z     tests::format_counts
2019-07-30T06:27:15.5182401Z     tests::format_counts
2019-07-30T06:27:15.5182431Z 
2019-07-30T06:27:15.5182479Z test result: FAILED. 13 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
2019-07-30T06:27:15.5182512Z 
2019-07-30T06:27:15.5197664Z error: test failed, to rerun pass '-p fmt_macros --lib'
2019-07-30T06:27:15.5213843Z 
2019-07-30T06:27:15.5213843Z 
2019-07-30T06:27:15.5214946Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--locked" "--color" "always" "--features" "" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "-p" "fmt_macros" "--" "--quiet"
2019-07-30T06:27:15.5215567Z 
2019-07-30T06:27:15.5215761Z 
2019-07-30T06:27:15.5225483Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-30T06:27:15.5225854Z Build completed unsuccessfully in 1:28:13
2019-07-30T06:27:15.5225854Z Build completed unsuccessfully in 1:28:13
2019-07-30T06:27:16.0780278Z ##[error]Bash exited with code '1'.
2019-07-30T06:27:16.0820359Z ##[section]Starting: Checkout
2019-07-30T06:27:16.0822414Z ==============================================================================
2019-07-30T06:27:16.0822497Z Task         : Get sources
2019-07-30T06:27:16.0822550Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@estebank estebank force-pushed the estebank:formatting-pos branch from 757c2fd to 9e59d74 Jul 30, 2019

@alexcrichton
Copy link
Member

left a comment

Looks reasonable to me! I tend to not review the error-generation code too too carefully, but the error messages look fantastic and I've largely just got one stylistic request on the fmt_macros crate

@@ -554,24 +577,25 @@ impl<'a> Parser<'a> {
/// Parses a Count parameter at the current position. This does not check
/// for 'CountIsNextParam' because that is only used in precision, not
/// width.
fn count(&mut self) -> Count {
fn count(&mut self, start: usize) -> (Count, Option<InnerSpan>) {

This comment has been minimized.

Copy link
@alexcrichton

alexcrichton Jul 31, 2019

Member

This seems like it's pretty tailored in the implementation, but perhaps this could be somewhat more generalized? For example instead of modifying existing methods and having some which return a span and some which don't (in addition to passing around start spans and such) could one new function be added liek:

fn span<R>(&mut self, f: impl FnOnce(&mut Self) -> R) -> (R, Span) {
    // ...
}

and that's called like let (count, span) = self.span(|me| me.count()); or something like that?

This comment has been minimized.

Copy link
@estebank

estebank Jul 31, 2019

Author Contributor

The thing is that the actual span for the thing being composed requires some passing of location between different methods. count in particular is only used in two places and both care about the span. These methods are meant to only be used from a single module, which is why I didn't bother with an externally pleasing api surface for them.

src/libsyntax_ext/format.rs Show resolved Hide resolved
@alexcrichton

This comment has been minimized.

Copy link
Member

commented Aug 2, 2019

@bors: r+

Ok, sounds reasonable to me!

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 2, 2019

📌 Commit 22ea38d has been approved by alexcrichton

Centril added a commit to Centril/rust that referenced this pull request Aug 2, 2019

Rollup merge of rust-lang#63121 - estebank:formatting-pos, r=alexcric…
…hton

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.
@Centril Centril referenced this pull request Aug 2, 2019

bors added a commit that referenced this pull request Aug 2, 2019

Auto merge of #63228 - Centril:rollup-x39p5ga, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #63107 (Added support for armv7-unknown-linux-gnueabi/musleabi)
 - #63121 (On `format!()` arg count mismatch provide extra info)
 - #63196 (build_helper: try less confusing method names)
 - #63206 (remove unsupported test case)
 - #63208 (Round generator sizes to a multiple of their alignment)
 - #63212 (Pretty print attributes in `print_arg`)
 - #63215 (Clarify semantics of mem::zeroed)

Failed merges:

r? @ghost

@bors bors merged commit 22ea38d into rust-lang:master Aug 3, 2019

4 checks passed

pr Build #20190731.39 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details

phansch added a commit to phansch/rust-clippy that referenced this pull request Aug 3, 2019

Rustup to latest rustc master
Broken due to:

* rust-lang/rust#63180 (`Existential` -> `OpaqueTy`)
* rust-lang/rust#63121 (New fields for `FormatSpec`)

bors added a commit to rust-lang/rust-clippy that referenced this pull request Aug 3, 2019

Auto merge of #4328 - phansch:rustup, r=phansch
Rustup to latest rustc master

Broken due to:

* rust-lang/rust#63180 (`Existential` -> `OpaqueTy`)
* rust-lang/rust#63121 (New fields for `FormatSpec`)

bors added a commit to rust-lang/rust-clippy that referenced this pull request Aug 3, 2019

Auto merge of #4328 - phansch:rustup, r=phansch
Rustup to latest rustc master

Broken due to:

* rust-lang/rust#63180 (`Existential` -> `OpaqueTy`)
* rust-lang/rust#63121 (New fields for `FormatSpec`)

bors added a commit to rust-lang/rust-clippy that referenced this pull request Aug 3, 2019

Auto merge of #4328 - phansch:rustup, r=phansch
Rustup to latest rustc master

Broken due to:

changelog: none

* rust-lang/rust#63180 (`Existential` -> `OpaqueTy`)
* rust-lang/rust#63121 (New fields for `FormatSpec`)

bors added a commit to rust-lang/rust-clippy that referenced this pull request Aug 3, 2019

Auto merge of #4328 - phansch:rustup, r=phansch
Rustup to latest rustc master

Broken due to:

* rust-lang/rust#63180 (`Existential` -> `OpaqueTy`)
* rust-lang/rust#63121 (New fields for `FormatSpec`)

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.