emit error with span for empty asserts

Fixes #55547.
This commit is contained in:
Andy Russell 2018-12-03 20:45:25 -05:00
parent 9cd3bef4cf
commit a367cec6e3
No known key found for this signature in database
GPG key ID: BE2221033EDBC374
3 changed files with 28 additions and 0 deletions

View file

@ -24,6 +24,14 @@ pub fn expand_assert<'cx>(
tts: &[TokenTree],
) -> Box<dyn MacResult + 'cx> {
let mut parser = cx.new_parser_from_tts(tts);
if parser.token == token::Eof {
cx.struct_span_err(sp, "macro requires a boolean expression as an argument")
.span_label(sp, "boolean expression required")
.emit();
return DummyResult::expr(sp);
}
let cond_expr = panictry!(parser.parse_expr());
let custom_msg_args = if parser.eat(&token::Comma) {
let ts = parser.parse_tokens();