diff options
| author | Jonas Hietala <tradet.h@gmail.com> | 2014-07-18 18:34:49 +0200 |
|---|---|---|
| committer | Jonas Hietala <tradet.h@gmail.com> | 2014-07-18 19:25:46 +0200 |
| commit | 18717fcf6886b803e04bbe21689fd61becab1015 (patch) | |
| tree | 99b341f42cdb989fa2dd88b3c71908a34ef4ffa1 /src/libsyntax/ext | |
| parent | 5ddc7b4a252fbebee5f2ac87ed755139816d6823 (diff) | |
| download | rust-18717fcf6886b803e04bbe21689fd61becab1015.tar.gz rust-18717fcf6886b803e04bbe21689fd61becab1015.zip | |
Correct plural of arguments in format_args!
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/format.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 786fd953f89..d629bafe2b1 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -215,12 +215,21 @@ impl<'a, 'b> Context<'a, 'b> { } } + fn describe_num_args(&self) -> String { + if self.args.len() == 1 { + "there is 1 argument".to_string() + } else { + format!("there are {} arguments", self.args.len()) + } + } + fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) { match arg { Exact(arg) => { if self.args.len() <= arg { - let msg = format!("invalid reference to argument `{}` (there \ - are {} arguments)", arg, self.args.len()); + let msg = format!("invalid reference to argument `{}` ({:s})", + arg, self.describe_num_args()); + self.ecx.span_err(self.fmtsp, msg.as_slice()); return; } |
