Skip to content

Commit

Permalink
Add specific message for tuple struct invoked with suffixed numeric f…
Browse files Browse the repository at this point in the history
…ield name
  • Loading branch information
estebank committed Mar 26, 2019
1 parent 1bb3694 commit 8d1cc72
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/parser/issue-59418.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
14 changes: 13 additions & 1 deletion src/test/ui/parser/issue-59418.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8d1cc72

Please sign in to comment.