about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorZack M. Davis <code@zackmdavis.net>2018-06-23 16:49:09 -0700
committerZack M. Davis <code@zackmdavis.net>2018-06-23 22:57:37 -0700
commita417518173bae739d1aef50c6cf1a1e3bd4c4319 (patch)
treeb9128702ccb5e0139d58f31c6d4a5797a300fb82 /src/libsyntax/parse
parent4650361fb627f7dd6b8d5c1cee8a7a12a050ba80 (diff)
downloadrust-a417518173bae739d1aef50c6cf1a1e3bd4c4319.tar.gz
rust-a417518173bae739d1aef50c6cf1a1e3bd4c4319.zip
structured suggestion and rewording for `...` expression syntax error
Now that `..=` inclusive ranges are stabilized, people probably
shouldn't be using `...` even in patterns, even if it's still legal
there (see #51043). To avoid drawing attention to `...` being a real
thing, let's reword this message to just say "unexpected token" rather
"cannot be used in expressions".
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 5970f94b97d..955bdbdcf91 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4800,12 +4800,14 @@ impl<'a> Parser<'a> {
 
     fn err_dotdotdot_syntax(&self, span: Span) {
         self.diagnostic().struct_span_err(span, {
-            "`...` syntax cannot be used in expressions"
-        }).help({
-            "Use `..` if you need an exclusive range (a < b)"
-        }).help({
-            "or `..=` if you need an inclusive range (a <= b)"
-        }).emit();
+            "unexpected token: `...`"
+        }).span_suggestion_with_applicability(
+            span, "use `..` for an exclusive range", "..".to_owned(),
+            Applicability::MaybeIncorrect
+        ).span_suggestion_with_applicability(
+            span, "or `..=` for an inclusive range", "..=".to_owned(),
+            Applicability::MaybeIncorrect
+        ).emit();
     }
 
     // Parse bounds of a type parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.