Skip to content

Commit

Permalink
std: stop vec!() warning about unused mutability.
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
huonw committed Mar 7, 2014
1 parent 28e7631 commit ba05ca6
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

5 comments on commit ba05ca6

@bors
Copy link
Contributor

@bors bors commented on ba05ca6 Mar 7, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at huonw@ba05ca6

@bors
Copy link
Contributor

@bors bors commented on ba05ca6 Mar 7, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging huonw/rust/vec-macro = ba05ca6 into auto

@bors
Copy link
Contributor

@bors bors commented on ba05ca6 Mar 7, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huonw/rust/vec-macro = ba05ca6 merged ok, testing candidate = 33768c4

@bors
Copy link
Contributor

@bors bors commented on ba05ca6 Mar 7, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on ba05ca6 Mar 7, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 33768c4

Please sign in to comment.