From 96d73536782fb4a6a4b98db330ac5446c63a8005 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 30 Mar 2020 09:20:55 +0200 Subject: [PATCH] parse_and_disallow_postfix_after_cast: account for `ExprKind::Err`. --- src/librustc_parse/parser/expr.rs | 1 + .../parser/issue-70552-ascription-in-parens-after-call.rs | 3 +++ .../issue-70552-ascription-in-parens-after-call.stderr | 8 ++++++++ 3 files changed, 12 insertions(+) create mode 100644 src/test/ui/parser/issue-70552-ascription-in-parens-after-call.rs create mode 100644 src/test/ui/parser/issue-70552-ascription-in-parens-after-call.stderr diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index b205a4b322229..cbff99f8da612 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -638,6 +638,7 @@ impl<'a> Parser<'a> { ExprKind::MethodCall(_, _) => "a method call", ExprKind::Call(_, _) => "a function call", ExprKind::Await(_) => "`.await`", + ExprKind::Err => return Ok(with_postfix), _ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"), } ); diff --git a/src/test/ui/parser/issue-70552-ascription-in-parens-after-call.rs b/src/test/ui/parser/issue-70552-ascription-in-parens-after-call.rs new file mode 100644 index 0000000000000..9b6dd7db4beb3 --- /dev/null +++ b/src/test/ui/parser/issue-70552-ascription-in-parens-after-call.rs @@ -0,0 +1,3 @@ +fn main() { + expr as fun()(:); //~ ERROR expected expression +} diff --git a/src/test/ui/parser/issue-70552-ascription-in-parens-after-call.stderr b/src/test/ui/parser/issue-70552-ascription-in-parens-after-call.stderr new file mode 100644 index 0000000000000..f03c92e1b1f17 --- /dev/null +++ b/src/test/ui/parser/issue-70552-ascription-in-parens-after-call.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `:` + --> $DIR/issue-70552-ascription-in-parens-after-call.rs:2:19 + | +LL | expr as fun()(:); + | ^ expected expression + +error: aborting due to previous error +