diff options
| author | bors <bors@rust-lang.org> | 2014-07-20 09:31:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-20 09:31:29 +0000 |
| commit | 4f55b52b1ad9f24c91864ed261b9629c08a46086 (patch) | |
| tree | d077c17f4bff8ed5d98ea253a1fcdb3cef8fd159 /src/libsyntax/ext | |
| parent | 50481f55030f02543e1b3b6ae008d77b1cef3e98 (diff) | |
| parent | 820a55857a132a14f5a69960f7cfbeec39b5360f (diff) | |
| download | rust-4f55b52b1ad9f24c91864ed261b9629c08a46086.tar.gz rust-4f55b52b1ad9f24c91864ed261b9629c08a46086.zip | |
auto merge of #15785 : treeman/rust/fix-15780, r=alexcrichton
Fix for #15780.
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..4b245f2c9fd 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 { + match self.args.len() { + 0 => "no arguments given".to_string(), + 1 => "there is 1 argument".to_string(), + x => format!("there are {} arguments", x), + } + } + 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; } |
