Skip to content

Commit 8310320

Browse files
authored
Rollup merge of #70632 - tspiteri:vec-new, r=sfackler
expand vec![] to Vec::new() The current expansion of `vec![]` calls `into_vec` on a boxed slice, which results in longer IR, and even after optimization, some unwinding artifacts are still present in the IR. This PR uses `Vec::new()` for `vec![]`. This also allows `vec![]` to be used in const expressions.
2 parents 0979a28 + 4d8273d commit 8310320

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/liballoc/macros.rs

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#[stable(feature = "rust1", since = "1.0.0")]
3737
#[allow_internal_unstable(box_syntax)]
3838
macro_rules! vec {
39+
() => (
40+
$crate::vec::Vec::new()
41+
);
3942
($elem:expr; $n:expr) => (
4043
$crate::vec::from_elem($elem, $n)
4144
);
@@ -51,6 +54,9 @@ macro_rules! vec {
5154
// NB see the slice::hack module in slice.rs for more information
5255
#[cfg(test)]
5356
macro_rules! vec {
57+
() => (
58+
$crate::vec::Vec::new()
59+
);
5460
($elem:expr; $n:expr) => (
5561
$crate::vec::from_elem($elem, $n)
5662
);

0 commit comments

Comments
 (0)