about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-01 00:27:26 +0200
committerGitHub <noreply@github.com>2020-04-01 00:27:26 +0200
commit8310320ebd68d5f23ad21bb5a15326abeaf91dff (patch)
tree21ba3ae00a56b802477ae80fbbeec3187dfe1c5f /src/liballoc
parent0979a2871c9fe46832a1274f8ad62c072af85f6a (diff)
parent4d8273dea5d2f398c473dd4a9c8a178dadc5be4c (diff)
downloadrust-8310320ebd68d5f23ad21bb5a15326abeaf91dff.tar.gz
rust-8310320ebd68d5f23ad21bb5a15326abeaf91dff.zip
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.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/macros.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs
index 422d3486f92..4bc0c3a079d 100644
--- a/src/liballoc/macros.rs
+++ b/src/liballoc/macros.rs
@@ -36,6 +36,9 @@
 #[stable(feature = "rust1", since = "1.0.0")]
 #[allow_internal_unstable(box_syntax)]
 macro_rules! vec {
+    () => (
+        $crate::vec::Vec::new()
+    );
     ($elem:expr; $n:expr) => (
         $crate::vec::from_elem($elem, $n)
     );
@@ -51,6 +54,9 @@ macro_rules! vec {
 // NB see the slice::hack module in slice.rs for more information
 #[cfg(test)]
 macro_rules! vec {
+    () => (
+        $crate::vec::Vec::new()
+    );
     ($elem:expr; $n:expr) => (
         $crate::vec::from_elem($elem, $n)
     );