Skip to content

Commit 33768c4

Browse files
committed
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.
2 parents b1d104c + ba05ca6 commit 33768c4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libstd/macros.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,14 @@ macro_rules! try(
366366
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
367367
)
368368

369+
/// Create a `std::vec_ng::Vec` containing the arguments.
369370
#[macro_export]
370371
macro_rules! vec(
371372
($($e:expr),*) => ({
372-
let mut temp = ::std::vec_ng::Vec::new();
373-
$(temp.push($e);)*
374-
temp
373+
// leading _ to allow empty construction without a warning.
374+
let mut _temp = ::std::vec_ng::Vec::new();
375+
$(_temp.push($e);)*
376+
_temp
375377
})
376378
)
377379

0 commit comments

Comments
 (0)