1
Fork 0

auto merge of #12753 : huonw/rust/vec-macro, r=cmr

If no arguments are given to `vec!` then no pushes are emitted and
so the compiler (rightly) complains that the mutability of `temp` is
never used.

This behaviour is rather annoying for users.
This commit is contained in:
bors 2014-03-07 02:51:39 -08:00
commit 33768c46ec

View file

@ -366,12 +366,14 @@ macro_rules! try(
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
)
/// Create a `std::vec_ng::Vec` containing the arguments.
#[macro_export]
macro_rules! vec(
($($e:expr),*) => ({
let mut temp = ::std::vec_ng::Vec::new();
$(temp.push($e);)*
temp
// leading _ to allow empty construction without a warning.
let mut _temp = ::std::vec_ng::Vec::new();
$(_temp.push($e);)*
_temp
})
)