diff options
| author | bors <bors@rust-lang.org> | 2014-03-07 02:51:39 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-03-07 02:51:39 -0800 |
| commit | 33768c46ec980a911284d77804e5e45ead6530eb (patch) | |
| tree | a16263c2c101d88f2a7378129126664f7ac80262 /src/libstd | |
| parent | b1d104c644cb023d32bfb8c016110b1787c564ba (diff) | |
| parent | ba05ca6962dcccfffe3d48c8cd69ed1a75bb93ca (diff) | |
| download | rust-33768c46ec980a911284d77804e5e45ead6530eb.tar.gz rust-33768c46ec980a911284d77804e5e45ead6530eb.zip | |
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.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index ba72e1f2549..f0ea90a4aed 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -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 }) ) |
