Skip to content

Commit

Permalink
auto merge of #12753 : huonw/rust/vec-macro, r=cmr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 7, 2014
2 parents b1d104c + ba05ca6 commit 33768c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
)

Expand Down

0 comments on commit 33768c4

Please sign in to comment.