From dcfbebe7bb192f7680034d407918324684188f37 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Tue, 19 Aug 2025 08:50:45 +0800 Subject: [PATCH] Remove tuple index carve out This is being proposed to be removed in as we never intended for this to be valid syntax. Also include an invalid tuple index with underscore example. --- src/tokens.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tokens.md b/src/tokens.md index 88b4c0b5c..d182547ed 100644 --- a/src/tokens.md +++ b/src/tokens.md @@ -624,7 +624,7 @@ r[lex.token.literal.int.tuple-field] r[lex.token.literal.int.tuple-field.syntax] ```grammar,lexer -TUPLE_INDEX -> INTEGER_LITERAL +TUPLE_INDEX -> DEC_LITERAL | BIN_LITERAL | OCT_LITERAL | HEX_LITERAL ``` r[lex.token.literal.int.tuple-field.intro] @@ -637,6 +637,8 @@ start with `0` and each successive index increments the value by `1` as a decimal value. Thus, only decimal values will match, and the value must not have any extra `0` prefix characters. +Tuple indices may not include any suffixes (such as `usize`). + ```rust,compile_fail let example = ("dog", "cat", "horse"); let dog = example.0; @@ -644,11 +646,10 @@ let cat = example.1; // The following examples are invalid. let cat = example.01; // ERROR no field named `01` let horse = example.0b10; // ERROR no field named `0b10` +let unicorn = example.0usize; // ERROR suffixes on a tuple index are invalid +let underscore = example.0_0; // ERROR no field `0_0` on type `(&str, &str, &str)` ``` -> [!NOTE] -> Tuple indices may include certain suffixes, but this is not intended to be valid, and may be removed in a future version. See for more information. - r[lex.token.literal.float] #### Floating-point literals