Skip to content

Commit b19e1b3

Browse files
committed
auto merge of #13278 : lifthrasiir/rust/vec-macro-with-trailing-comma, r=alexcrichton
Fixes #12910.
2 parents 9a33330 + 016a4b0 commit b19e1b3

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/libstd/macros.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ macro_rules! vec(
273273
let mut _temp = ::std::vec::Vec::new();
274274
$(_temp.push($e);)*
275275
_temp
276-
})
276+
});
277+
($($e:expr),+,) => (vec!($($e),+))
277278
)
278279

279280

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
vec!(,); //~ ERROR unexpected token
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
12+
pub fn main() {
13+
assert_eq!(vec!(1), vec!(1,));
14+
assert_eq!(vec!(1, 2, 3), vec!(1, 2, 3,));
15+
}

0 commit comments

Comments
 (0)