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

Fix ice caused by shorthand fields in NoFieldsForFnCall #111531

Merged
merged 2 commits into from
May 15, 2023
Merged
Changes from all commits
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
4 changes: 4 additions & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
@@ -1180,6 +1180,10 @@ impl<'a> Parser<'a> {
self.restore_snapshot(snapshot);
let close_paren = self.prev_token.span;
let span = lo.to(close_paren);
// filter shorthand fields
let fields: Vec<_> =
fields.into_iter().filter(|field| !field.is_shorthand).collect();

if !fields.is_empty() &&
// `token.kind` should not be compared here.
// This is because the `snapshot.token.kind` is treated as the same as
3 changes: 3 additions & 0 deletions tests/ui/parser/issues/issue-111416.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments
}
18 changes: 18 additions & 0 deletions tests/ui/parser/issues/issue-111416.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: invalid `struct` delimiters or `fn` call arguments
--> $DIR/issue-111416.rs:2:14
|
LL | let my = monad_bind(mx, T: Try);
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: if `monad_bind` is a struct, use braces as delimiters
|
LL | let my = monad_bind { mx, T: Try };
| ~ ~
help: if `monad_bind` is a function, use the arguments directly
|
LL - let my = monad_bind(mx, T: Try);
LL + let my = monad_bind(mx, Try);
|

error: aborting due to previous error