about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2019-01-21 21:16:46 +0100
committerDavid Wood <david@davidtw.co>2019-01-21 22:42:54 +0100
commit3f0fc9b03569e03dbdf5fdc3a67f246aad3b40b8 (patch)
treec7b17737e5655291daec174928546ece71d8dba5 /src/libsyntax/parse/parser.rs
parent6c399d155c6307563a2022fe98bc2e596af1cfc4 (diff)
downloadrust-3f0fc9b03569e03dbdf5fdc3a67f246aad3b40b8.tar.gz
rust-3f0fc9b03569e03dbdf5fdc3a67f246aad3b40b8.zip
Pluralize error messages.
This commit pluralizes error messages when more than a single trailing
`>` character is present.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index d7c209d12a8..6a881eb6241 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2869,11 +2869,18 @@ impl<'a> Parser<'a> {
             self.eat_to_tokens(&[&token::OpenDelim(token::Paren)]);
             let span = lo.until(self.span);
 
+            // We needn't check `encountered_gt` to determine if we should pluralize "bracket".
+            // `encountered_gt` can only represent a single `>` character, if `number_of_shr >= 1`
+            // then there is either `>>` or `>>>` - in either case a plural is warranted.
+            let plural = number_of_shr >= 1;
             self.diagnostic()
-                .struct_span_err(span, "unmatched angle bracket")
+                .struct_span_err(
+                    span,
+                    &format!("unmatched angle bracket{}", if plural { "s" } else { "" }),
+                )
                 .span_suggestion_with_applicability(
                     span,
-                    "remove extra angle bracket",
+                    &format!("remove extra angle bracket{}", if plural { "s" } else { "" }),
                     String::new(),
                     Applicability::MachineApplicable,
                 )