Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject integer suffix when tuple indexing #59421

Merged
merged 5 commits into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3205,14 +3205,7 @@ impl<'a> Parser<'a> {
let field = ExprKind::Field(e, Ident::new(name, span));
e = self.mk_expr(lo.to(span), field, ThinVec::new());

if let Some(suffix) = suffix {
let mut err = self.diagnostic().struct_span_err(
span,
"suffixes on tuple indexes are invalid",
);
err.span_label(span, format!("invalid suffix `{}`", suffix));
err.emit();
}
self.expect_no_suffix(span, "tuple index", suffix);
estebank marked this conversation as resolved.
Show resolved Hide resolved
}
token::Literal(token::Float(n), _suf) => {
self.bump();
Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/parser/issue-59418.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ struct X(i32,i32,i32);
fn main() {
let a = X(1, 2, 3);
let b = a.1suffix;
estebank marked this conversation as resolved.
Show resolved Hide resolved
//~^ ERROR suffixes on tuple indexes are invalid
//~^ ERROR tuple index with a suffix is invalid
println!("{}", b);
let c = (1, 2, 3);
let d = c.1suffix;
//~^ ERROR suffixes on tuple indexes are invalid
//~^ ERROR tuple index with a suffix is invalid
println!("{}", d);
}

8 changes: 4 additions & 4 deletions src/test/ui/parser/issue-59418.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error: suffixes on tuple indexes are invalid
error: tuple index with a suffix is invalid
--> $DIR/issue-59418.rs:5:15
|
LL | let b = a.1suffix;
| ^^^^^^^ invalid suffix `suffix`
| ^^^^^^^ tuple index with a suffix is invalid

error: suffixes on tuple indexes are invalid
error: tuple index with a suffix is invalid
--> $DIR/issue-59418.rs:9:15
|
LL | let d = c.1suffix;
| ^^^^^^^ invalid suffix `suffix`
| ^^^^^^^ tuple index with a suffix is invalid

error: aborting due to 2 previous errors