Fix ice caused by shorthand fields in NoFieldsForFnCall
This commit is contained in:
parent
69fef92ab2
commit
ce6cfc37d0
3 changed files with 29 additions and 0 deletions
|
@ -1180,6 +1180,13 @@ impl<'a> Parser<'a> {
|
||||||
self.restore_snapshot(snapshot);
|
self.restore_snapshot(snapshot);
|
||||||
let close_paren = self.prev_token.span;
|
let close_paren = self.prev_token.span;
|
||||||
let span = lo.to(close_paren);
|
let span = lo.to(close_paren);
|
||||||
|
// filter shorthand fields
|
||||||
|
let fields: Vec<_> = fields
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(
|
||||||
|
|field| if !field.is_shorthand { Some(field) } else { None },
|
||||||
|
)
|
||||||
|
.collect();
|
||||||
if !fields.is_empty() &&
|
if !fields.is_empty() &&
|
||||||
// `token.kind` should not be compared here.
|
// `token.kind` should not be compared here.
|
||||||
// This is because the `snapshot.token.kind` is treated as the same as
|
// This is because the `snapshot.token.kind` is treated as the same as
|
||||||
|
|
4
tests/ui/parser/issues/issue-111416.rs
Normal file
4
tests/ui/parser/issues/issue-111416.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments
|
||||||
|
}
|
18
tests/ui/parser/issues/issue-111416.stderr
Normal file
18
tests/ui/parser/issues/issue-111416.stderr
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
error: invalid `struct` delimiters or `fn` call arguments
|
||||||
|
--> $DIR/issue-111416.rs:3: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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue