about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-04-30 20:37:42 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-04-30 20:37:42 -0700
commit617ce2b7ee330bbcc7ce8eb87160c71ad995639b (patch)
tree2737b98c97ad94492241db0f67c7ab52666085a0 /src/libsyntax/parse
parentbff0be37845a96010fa2161bbf137fadfe763ae5 (diff)
downloadrust-617ce2b7ee330bbcc7ce8eb87160c71ad995639b.tar.gz
rust-617ce2b7ee330bbcc7ce8eb87160c71ad995639b.zip
Reword ambigous parse error to fit with the current error
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 3c7f477cc8f..fbd1203dec9 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3649,13 +3649,14 @@ impl<'a> Parser<'a> {
                 return Ok(lhs);
             }
             (true, Some(_)) => {
-                // #54186, #54482, #59975
                 // We've found an expression that would be parsed as a statement, but the next
                 // token implies this should be parsed as an expression.
-                let mut err = self.sess.span_diagnostic.struct_span_err(
-                    self.span,
-                    "ambiguous parse",
-                );
+                // For example: `if let Some(x) = x { x } else { 0 } / 2`
+                let mut err = self.sess.span_diagnostic.struct_span_err(self.span, &format!(
+                    "expected expression, found `{}`",
+                    pprust::token_to_string(&self.token),
+                ));
+                err.span_label(self.span, "expected expression");
                 let snippet = self.sess.source_map().span_to_snippet(lhs.span)
                     .unwrap_or_else(|_| pprust::expr_to_string(&lhs));
                 err.span_suggestion(