about summary refs log tree commit diff
path: root/src/librustc_parse/parser
diff options
context:
space:
mode:
authorDavid Ross <daboross@daboross.net>2020-02-15 16:18:20 -0800
committerDavid Ross <daboross@daboross.net>2020-02-15 19:51:02 -0800
commit4fc0532269f40c2870936faaebcdd14539613411 (patch)
tree4a1db5530fb83dd6f38aee1fc1fa517efbeb8522 /src/librustc_parse/parser
parent5ce9b80c0f93e54bc83f6cb15942ecdce31c3e6a (diff)
downloadrust-4fc0532269f40c2870936faaebcdd14539613411.tar.gz
rust-4fc0532269f40c2870936faaebcdd14539613411.zip
Type ascription outputs a Type, not Cast
Previously this just errored out on all usages of type ascription,
which isn't helpful.
Diffstat (limited to 'src/librustc_parse/parser')
-rw-r--r--src/librustc_parse/parser/expr.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index 76e4a80878f..645e680d15f 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -645,7 +645,9 @@ impl<'a> Parser<'a> {
 
         // Check if an illegal postfix operator has been added after the cast.
         // If the resulting expression is not a cast, or has a different memory location, it is an illegal postfix operator.
-        if !matches!(with_postfix.kind, ExprKind::Cast(_, _)) || after_hash != before_hash {
+        if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _))
+            || after_hash != before_hash
+        {
             let expr_str = self.span_to_snippet(span);
 
             let msg = format!(