about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-07-30 20:39:48 +0530
committerGitHub <noreply@github.com>2022-07-30 20:39:48 +0530
commitcfd231a0cbcdbc39543c6f9e5fa2216244a89858 (patch)
tree13e392f26f59ffc5cc14cfe4aaad71b1715ce5c0 /compiler/rustc_parse/src/parser/expr.rs
parenteb378d2015d10b6b99955512ab005665f417e014 (diff)
parent7cdd937bb821881f82ee367757cc45ad74e8698b (diff)
downloadrust-cfd231a0cbcdbc39543c6f9e5fa2216244a89858.tar.gz
rust-cfd231a0cbcdbc39543c6f9e5fa2216244a89858.zip
Rollup merge of #99895 - compiler-errors:type-ascription-aint-cast, r=davidtwco
don't call type ascription "cast"

Noticed in #99885
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 43b48613976..c0f661f7dbb 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -827,11 +827,12 @@ impl<'a> Parser<'a> {
         cast_expr: P<Expr>,
     ) -> PResult<'a, P<Expr>> {
         let span = cast_expr.span;
-        let maybe_ascription_span = if let ExprKind::Type(ascripted_expr, _) = &cast_expr.kind {
-            Some(ascripted_expr.span.shrink_to_hi().with_hi(span.hi()))
-        } else {
-            None
-        };
+        let (cast_kind, maybe_ascription_span) =
+            if let ExprKind::Type(ascripted_expr, _) = &cast_expr.kind {
+                ("type ascription", Some(ascripted_expr.span.shrink_to_hi().with_hi(span.hi())))
+            } else {
+                ("cast", None)
+            };
 
         // Save the memory location of expr before parsing any following postfix operators.
         // This will be compared with the memory location of the output expression.
@@ -844,7 +845,7 @@ impl<'a> Parser<'a> {
         // 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(_, _) | ExprKind::Type(_, _)) || changed {
             let msg = format!(
-                "casts cannot be followed by {}",
+                "{cast_kind} cannot be followed by {}",
                 match with_postfix.kind {
                     ExprKind::Index(_, _) => "indexing",
                     ExprKind::Try(_) => "`?`",