diff options
| author | Knium_ <hi.im.knium@gmail.com> | 2019-01-30 13:50:44 +0900 |
|---|---|---|
| committer | Knium_ <hi.im.knium@gmail.com> | 2019-01-30 13:50:44 +0900 |
| commit | 62867b499291a69f5df16a60228c6bcedc5e4225 (patch) | |
| tree | 1ede3ab49ddef80590e8286619a5dc383f2243eb /src/libsyntax/parse/parser.rs | |
| parent | d8a0dd7ae88023bd09fa4b86c9ca1f6ed8095b43 (diff) | |
| download | rust-62867b499291a69f5df16a60228c6bcedc5e4225.tar.gz rust-62867b499291a69f5df16a60228c6bcedc5e4225.zip | |
Suggest to add each of `|` and `()` when unexpected `,` is found in pattern
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 |
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); |
