Skip to content

Commit 7a1f3e7

Browse files
authored
Rollup merge of #111531 - chenyukang:yukang-fix-111416-ice, r=compiler-errors
Fix ice caused by shorthand fields in NoFieldsForFnCall Fixes #111416
2 parents 28bc874 + 83789b8 commit 7a1f3e7

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

compiler/rustc_parse/src/parser/expr.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,10 @@ 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<_> =
1185+
fields.into_iter().filter(|field| !field.is_shorthand).collect();
1186+
11831187
if !fields.is_empty() &&
11841188
// `token.kind` should not be compared here.
11851189
// This is because the `snapshot.token.kind` is treated as the same as
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments
3+
}
+18
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:2: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)