about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-02-12 03:34:57 +0000
committerbors <bors@rust-lang.org>2017-02-12 03:34:57 +0000
commit410d807e46b2538ab3ab2ebefcc68b44442d025a (patch)
tree77a3a832110895cb4abf81a2f8ebcb4241a21003 /src/rustllvm/RustWrapper.cpp
parent912bc14a6b25bac66822766b09dcfb3c6263757d (diff)
parent65435e14febd9d8aa1d40a19cd1adb427263c48e (diff)
downloadrust-410d807e46b2538ab3ab2ebefcc68b44442d025a.tar.gz
rust-410d807e46b2538ab3ab2ebefcc68b44442d025a.zip
Auto merge of #39554 - zackmdavis:assert_eq_has_a_terrible_error_message_when_given_a_trailing_comma, r=BurntSushi
improve error message when two-arg assert_eq! receives a trailing comma

Previously, `assert_eq!(left, right,)` (respectively, `assert_ne!(left,
right,)`; note the trailing comma) would result in a confusing "requires
at least a format string argument" error. In reality, a format string is
optional, but the trailing comma puts us into the "match a token tree of
zero or more tokens" branch of the macro (in order to support the
optional format string), and passing the empty token tree into
`format_args!` results in the confusing error. If instead we match a
token tree of one or more tokens, we get a much more sensible
"unexpected end of macro invocation" error.

While we're here, fix up a stray space before a comma in the match
guards.

Resolves #39369.

-----

**Before:**
```
$ rustc scratch.rs
error: requires at least a format string argument
 --> scratch.rs:2:5
  |
2 |     assert_eq!(1, 2,);
  |     ^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in a macro outside of the current crate

error: aborting due to previous error
```

**After:**
```
$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc scratch.rs
error: unexpected end of macro invocation
 --> scratch.rs:2:20
  |
2 |     assert_eq!(1, 2,);
  |                    ^
```
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions