diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bb3dc8edfb001..71dde91e65455 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2491,7 +2491,8 @@ impl<'a> Parser<'a> { } fn parse_field_name(&mut self) -> PResult<'a, Ident> { - if let token::Literal(token::Integer(name), None) = self.token { + if let token::Literal(token::Integer(name), suffix) = self.token { + self.expect_no_suffix(self.span, "a tuple index", suffix); self.bump(); Ok(Ident::new(name, self.prev_span)) } else { diff --git a/src/test/ui/parser/issue-59418.rs b/src/test/ui/parser/issue-59418.rs index a37af2180bf1b..0fa191d4a7ef4 100644 --- a/src/test/ui/parser/issue-59418.rs +++ b/src/test/ui/parser/issue-59418.rs @@ -9,4 +9,10 @@ fn main() { let d = c.1suffix; //~^ ERROR suffixes on a tuple index are invalid println!("{}", d); + let s = X { 0suffix: 0, 1: 1, 2: 2 }; + //~^ ERROR suffixes on a tuple index are invalid + match s { + X { 0suffix: _, .. } => {} + //~^ ERROR suffixes on a tuple index are invalid + } } diff --git a/src/test/ui/parser/issue-59418.stderr b/src/test/ui/parser/issue-59418.stderr index ca7d4cfda7294..347051e9f921c 100644 --- a/src/test/ui/parser/issue-59418.stderr +++ b/src/test/ui/parser/issue-59418.stderr @@ -10,5 +10,17 @@ error: suffixes on a tuple index are invalid LL | let d = c.1suffix; | ^^^^^^^ invalid suffix `suffix` -error: aborting due to 2 previous errors +error: suffixes on a tuple index are invalid + --> $DIR/issue-59418.rs:12:17 + | +LL | let s = X { 0suffix: 0, 1: 1, 2: 2 }; + | ^^^^^^^ invalid suffix `suffix` + +error: suffixes on a tuple index are invalid + --> $DIR/issue-59418.rs:15:13 + | +LL | X { 0suffix: _, .. } => {} + | ^^^^^^^ invalid suffix `suffix` + +error: aborting due to 4 previous errors