diff options
| author | bors <bors@rust-lang.org> | 2014-06-24 19:36:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-24 19:36:47 +0000 |
| commit | 87f3741fdf6356d57d22f8154cf6069a83dec8d7 (patch) | |
| tree | 4a22a164a3a5fba60bf9f81564650c79461f7268 /src | |
| parent | 719ffc2484e59476dc153d3503a5adfe79487e11 (diff) | |
| parent | 85467b6b41e4294f3956a425535a3245904625f0 (diff) | |
| download | rust-87f3741fdf6356d57d22f8154cf6069a83dec8d7.tar.gz rust-87f3741fdf6356d57d22f8154cf6069a83dec8d7.zip | |
auto merge of #15118 : stepancheg/rust/concat, r=alexcrichton
(And in other extensions implemented with `get_exprs_from_tts` function).
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/concat.rs | 4 |
2 files changed, 8 insertions, 3 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) } diff --git a/src/test/run-pass/concat.rs b/src/test/run-pass/concat.rs index 64209f24460..dd184c90295 100644 --- a/src/test/run-pass/concat.rs +++ b/src/test/run-pass/concat.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -11,6 +11,8 @@ pub fn main() { assert_eq!(format!(concat!("foo", "bar", "{}"), "baz"), "foobarbaz".to_string()); assert_eq!(format!(concat!()), "".to_string()); + // check trailing comma is allowed in concat + assert_eq!(concat!("qux", "quux",).to_string(), "quxquux".to_string()); assert_eq!( concat!(1, 2i, 3u, 4f32, 4.0, 'a', true, ()), |
