Reject integer suffix when tuple indexing by estebank · Pull Request #59421 · rust-lang/rust (original) (raw)

Added the requested changes. r? @petrochenkov, can you take a look to give final approval?

For the case you asked the output is

error: expected identifier, found `0suffix`
  --> src/main.rs:12:17
   |
12 |     let s = X { 0suffix: 0, 1: 1, 2: 2 };
   |             -   ^^^^^^^ expected identifier
   |             |
   |             while parsing this struct

error: expected identifier, found `0suffix`
  --> src/main.rs:15:13
   |
15 |         X { 0suffix: _, .. } => {}
   |             ^^^^^^^ expected identifier

error[E0063]: missing field `0` in initializer of `X`
  --> src/main.rs:12:13
   |
12 |     let s = X { 0suffix: 0, 1: 1, 2: 2 };
   |             ^ missing `0`

error[E0027]: pattern does not mention fields `0`, `1`, `2`
  --> src/main.rs:15:9
   |
15 |         X { 0suffix: _, .. } => {}
   |         ^^^^^^^^^^^^^^^^^^^^ missing fields `0`, `1`, `2`
   |
   = note: trying to match a tuple variant with a struct variant pattern

Which is why I think it shouldn't be added to the test, as it is not handled by this PR.