Skip to content

Commit ce6cfc3

Browse files
committed
Fix ice caused by shorthand fields in NoFieldsForFnCall
1 parent 69fef92 commit ce6cfc3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,13 @@ impl<'a> Parser<'a> {
11801180
self.restore_snapshot(snapshot);
11811181
let close_paren = self.prev_token.span;
11821182
let span = lo.to(close_paren);
1183+
// filter shorthand fields
1184+
let fields: Vec<_> = fields
1185+
.into_iter()
1186+
.filter_map(
1187+
|field| if !field.is_shorthand { Some(field) } else { None },
1188+
)
1189+
.collect();
11831190
if !fields.is_empty() &&
11841191
// `token.kind` should not be compared here.
11851192
// This is because the `snapshot.token.kind` is treated as the same as
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
fn main() {
3+
let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments
4+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: invalid `struct` delimiters or `fn` call arguments
2+
--> $DIR/issue-111416.rs:3:14
3+
|
4+
LL | let my = monad_bind(mx, T: Try);
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
help: if `monad_bind` is a struct, use braces as delimiters
8+
|
9+
LL | let my = monad_bind { mx, T: Try };
10+
| ~ ~
11+
help: if `monad_bind` is a function, use the arguments directly
12+
|
13+
LL - let my = monad_bind(mx, T: Try);
14+
LL + let my = monad_bind(mx, Try);
15+
|
16+
17+
error: aborting due to previous error
18+

0 commit comments

Comments
 (0)