about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-01-31 02:10:40 +0100
committerGitHub <noreply@github.com>2019-01-31 02:10:40 +0100
commitab844daadb8c513488c9dc349120a58c4a71b27b (patch)
treede2a4c46c15eef4c5bf256d2e2d8bfaf71c93ef4 /src/libsyntax/parse/parser.rs
parent147311c5fc62537da8eb9c6f69536bec6719d534 (diff)
parent62867b499291a69f5df16a60228c6bcedc5e4225 (diff)
downloadrust-ab844daadb8c513488c9dc349120a58c4a71b27b.tar.gz
rust-ab844daadb8c513488c9dc349120a58c4a71b27b.zip
Rollup merge of #57008 - Knium:misleading-try-adding-parentheses-in-match-with-comma, r=oli-obk
suggest `|` when `,` founds in invalid match value

Issue #54807
I get stuck on (what | how) I should implement...
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 65572102c59..514b2952c50 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -4381,9 +4381,14 @@ impl<'a> Parser<'a> {
             if let Ok(seq_snippet) = self.sess.source_map().span_to_snippet(seq_span) {
                 err.span_suggestion(
                     seq_span,
-                    "try adding parentheses",
+                    "try adding parentheses to match on a tuple..",
                     format!("({})", seq_snippet),
                     Applicability::MachineApplicable
+                ).span_suggestion(
+                    seq_span,
+                    "..or a vertical bar to match on multiple alternatives",
+                    format!("{}", seq_snippet.replace(",", " |")),
+                    Applicability::MachineApplicable
                 );
             }
             return Err(err);