Add specific message for tuple struct invoked with suffixed numeric field name
This commit is contained in:
parent
1bb3694b1a
commit
8d1cc72cf9
3 changed files with 21 additions and 2 deletions
|
@ -2491,7 +2491,8 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_field_name(&mut self) -> PResult<'a, Ident> {
|
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();
|
self.bump();
|
||||||
Ok(Ident::new(name, self.prev_span))
|
Ok(Ident::new(name, self.prev_span))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,4 +9,10 @@ fn main() {
|
||||||
let d = c.1suffix;
|
let d = c.1suffix;
|
||||||
//~^ ERROR suffixes on a tuple index are invalid
|
//~^ ERROR suffixes on a tuple index are invalid
|
||||||
println!("{}", d);
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,17 @@ error: suffixes on a tuple index are invalid
|
||||||
LL | let d = c.1suffix;
|
LL | let d = c.1suffix;
|
||||||
| ^^^^^^^ invalid suffix `suffix`
|
| ^^^^^^^ 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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue