diff options
| author | Stepan Koltsov <stepan.koltsov@gmail.com> | 2014-06-23 15:51:40 +0000 |
|---|---|---|
| committer | Stepan Koltsov <stepan.koltsov@gmail.com> | 2014-06-23 15:51:40 +0000 |
| commit | 85467b6b41e4294f3956a425535a3245904625f0 (patch) | |
| tree | 2acda31fa5a9388b507e9508659b5fc725bec85c /src/libsyntax | |
| parent | baa72085f41a4e935e671041899da7360f8ba151 (diff) | |
| download | rust-85467b6b41e4294f3956a425535a3245904625f0.tar.gz rust-85467b6b41e4294f3956a425535a3245904625f0.zip | |
Allow trailing comma in `concat!`
(And in other extensions implemented with `get_exprs_from_tts` function).
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 960894e6963..0d8373eac3c 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -593,11 +593,14 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt, .collect()); let mut es = Vec::new(); while p.token != token::EOF { - if es.len() != 0 && !p.eat(&token::COMMA) { + es.push(cx.expand_expr(p.parse_expr())); + if p.eat(&token::COMMA) { + continue; + } + if p.token != token::EOF { cx.span_err(sp, "expected token: `,`"); return None; } - es.push(cx.expand_expr(p.parse_expr())); } Some(es) } |
