summaryrefslogtreecommitdiffstats
path: root/third_party/rust/smallvec
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/rust/smallvec
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/smallvec')
-rw-r--r--third_party/rust/smallvec/.cargo-checksum.json2
-rw-r--r--third_party/rust/smallvec/Cargo.toml2
-rw-r--r--third_party/rust/smallvec/benches/bench.rs4
-rw-r--r--third_party/rust/smallvec/src/lib.rs66
-rw-r--r--third_party/rust/smallvec/src/tests.rs21
5 files changed, 55 insertions, 40 deletions
diff --git a/third_party/rust/smallvec/.cargo-checksum.json b/third_party/rust/smallvec/.cargo-checksum.json
index f8adf7532e..bdb1fcd312 100644
--- a/third_party/rust/smallvec/.cargo-checksum.json
+++ b/third_party/rust/smallvec/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"964f828a4ed019af9a728f6a0f63dc5860446c7b21abe2be1a0b92ddc82d1140","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0b28172679e0009b655da42797c03fd163a3379d5cfa67ba1f1655e974a2a1a9","README.md":"a01127c37308457e8d396b176fb790846be0978c173be3f13260b62efcef011b","benches/bench.rs":"e2a235d68be20996014c00468b369887d2041ce95486625de3cef35b8f2e4acd","debug_metadata/README.md":"4d7f1c1b2c25ce2231ef71864d06e54323867459035b53bc9e00f66a0a44f82e","debug_metadata/smallvec.natvis":"3092ddebd8fffc3486536d7f27f8c5eae3a8a093d45cd8eeb3946ea2b0c35a15","scripts/run_miri.sh":"74a9f9adc43f986e81977b03846f7dd00122a0150bd8ec3fe4842a1a787e0f07","src/arbitrary.rs":"22e55cfbf60374945b30e6d0855129eff67cd8b878cef6fa997e1f4be67b9e3d","src/lib.rs":"aed3176e0c74d7eb1d405ee096a4d1027626ed5f1bb65da4c0ef89f83b8f66ed","src/specialization.rs":"46433586203399251cba496d67b88d34e1be3c2b591986b77463513da1c66471","src/tests.rs":"d0a70bb7b4e1d0a174f2a195c8ab55280a40589bab7028999afd787b3fff6eae","tests/debugger_visualizer.rs":"185456ad253957fc0c9e904ff8a1135397ac991c29fa3c60f75d8d81f7463022","tests/macro.rs":"22ad4f6f104a599fdcba19cad8834105b8656b212fb6c7573a427d447f5db14f"},"package":"942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"} \ No newline at end of file
+{"files":{"Cargo.toml":"668bb964a243127d65605bb7a0d8d3c81bcbd8f7656a5b5734766ef534b4abcb","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0b28172679e0009b655da42797c03fd163a3379d5cfa67ba1f1655e974a2a1a9","README.md":"a01127c37308457e8d396b176fb790846be0978c173be3f13260b62efcef011b","benches/bench.rs":"d82015eae942ee5cf74ace8c3c260ee2c6b5bcbeeb87254d2c72622c747a708a","debug_metadata/README.md":"4d7f1c1b2c25ce2231ef71864d06e54323867459035b53bc9e00f66a0a44f82e","debug_metadata/smallvec.natvis":"3092ddebd8fffc3486536d7f27f8c5eae3a8a093d45cd8eeb3946ea2b0c35a15","scripts/run_miri.sh":"74a9f9adc43f986e81977b03846f7dd00122a0150bd8ec3fe4842a1a787e0f07","src/arbitrary.rs":"22e55cfbf60374945b30e6d0855129eff67cd8b878cef6fa997e1f4be67b9e3d","src/lib.rs":"25fe85b6ae7b3972211bf57aeded4c7b72c47e4d843c7a4ba66908442197b5a0","src/specialization.rs":"46433586203399251cba496d67b88d34e1be3c2b591986b77463513da1c66471","src/tests.rs":"29c6e5dad62ebfea74e5116ac4a344b127b91cfb769fe9ba8b02b53773cf7ec8","tests/debugger_visualizer.rs":"185456ad253957fc0c9e904ff8a1135397ac991c29fa3c60f75d8d81f7463022","tests/macro.rs":"22ad4f6f104a599fdcba19cad8834105b8656b212fb6c7573a427d447f5db14f"},"package":"e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"} \ No newline at end of file
diff --git a/third_party/rust/smallvec/Cargo.toml b/third_party/rust/smallvec/Cargo.toml
index 4a69944339..baba15315a 100644
--- a/third_party/rust/smallvec/Cargo.toml
+++ b/third_party/rust/smallvec/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "smallvec"
-version = "1.11.1"
+version = "1.13.1"
authors = ["The Servo Project Developers"]
description = "'Small vector' optimization: store up to a small number of items on the stack"
documentation = "https://docs.rs/smallvec/"
diff --git a/third_party/rust/smallvec/benches/bench.rs b/third_party/rust/smallvec/benches/bench.rs
index b52ee15504..b6a8b857d3 100644
--- a/third_party/rust/smallvec/benches/bench.rs
+++ b/third_party/rust/smallvec/benches/bench.rs
@@ -1,12 +1,10 @@
#![feature(test)]
#![allow(deprecated)]
-#[macro_use]
-extern crate smallvec;
extern crate test;
use self::test::Bencher;
-use smallvec::{ExtendFromSlice, SmallVec};
+use smallvec::{ExtendFromSlice, smallvec, SmallVec};
const VEC_SIZE: usize = 16;
const SPILLED_SIZE: usize = 100;
diff --git a/third_party/rust/smallvec/src/lib.rs b/third_party/rust/smallvec/src/lib.rs
index 8281fb1808..cadb5d8b15 100644
--- a/third_party/rust/smallvec/src/lib.rs
+++ b/third_party/rust/smallvec/src/lib.rs
@@ -149,8 +149,7 @@ use core::mem::ManuallyDrop;
/// - Create a [`SmallVec`] containing a given list of elements:
///
/// ```
-/// # #[macro_use] extern crate smallvec;
-/// # use smallvec::SmallVec;
+/// # use smallvec::{smallvec, SmallVec};
/// # fn main() {
/// let v: SmallVec<[_; 128]> = smallvec![1, 2, 3];
/// assert_eq!(v[0], 1);
@@ -162,8 +161,7 @@ use core::mem::ManuallyDrop;
/// - Create a [`SmallVec`] from a given element and size:
///
/// ```
-/// # #[macro_use] extern crate smallvec;
-/// # use smallvec::SmallVec;
+/// # use smallvec::{smallvec, SmallVec};
/// # fn main() {
/// let v: SmallVec<[_; 0x8000]> = smallvec![1; 3];
/// assert_eq!(v, SmallVec::from_buf([1, 1, 1]));
@@ -209,8 +207,7 @@ macro_rules! smallvec {
/// - Create a [`SmallVec`] containing a given list of elements:
///
/// ```
-/// # #[macro_use] extern crate smallvec;
-/// # use smallvec::SmallVec;
+/// # use smallvec::{smallvec_inline, SmallVec};
/// # fn main() {
/// const V: SmallVec<[i32; 3]> = smallvec_inline![1, 2, 3];
/// assert_eq!(V[0], 1);
@@ -222,8 +219,7 @@ macro_rules! smallvec {
/// - Create a [`SmallVec`] from a given element and size:
///
/// ```
-/// # #[macro_use] extern crate smallvec;
-/// # use smallvec::SmallVec;
+/// # use smallvec::{smallvec_inline, SmallVec};
/// # fn main() {
/// const V: SmallVec<[i32; 3]> = smallvec_inline![1; 3];
/// assert_eq!(V, SmallVec::from_buf([1, 1, 1]));
@@ -328,7 +324,7 @@ fn infallible<T>(result: Result<T, CollectionAllocErr>) -> T {
}
/// FIXME: use `Layout::array` when we require a Rust version where it’s stable
-/// https://github.com/rust-lang/rust/issues/55724
+/// <https://github.com/rust-lang/rust/issues/55724>
fn layout_array<T>(n: usize) -> Result<Layout, CollectionAllocErr> {
let size = mem::size_of::<T>()
.checked_mul(n)
@@ -430,7 +426,7 @@ impl<'a, T: 'a + Array> Drop for Drain<'a, T> {
/// An iterator which uses a closure to determine if an element should be removed.
///
/// Returned from [`SmallVec::drain_filter`][1].
-///
+///
/// [1]: struct.SmallVec.html#method.drain_filter
pub struct DrainFilter<'a, T, F>
where
@@ -815,7 +811,7 @@ impl<A: Array> SmallVec<A> {
/// Construct a new `SmallVec` from a `Vec<A::Item>`.
///
- /// Elements will be copied to the inline buffer if vec.capacity() <= Self::inline_capacity().
+ /// Elements will be copied to the inline buffer if `vec.capacity() <= Self::inline_capacity()`.
///
/// ```rust
/// use smallvec::SmallVec;
@@ -970,7 +966,7 @@ impl<A: Array> SmallVec<A> {
}
/// Returns a tuple with (data ptr, len, capacity)
- /// Useful to get all SmallVec properties with a single check of the current storage variant.
+ /// Useful to get all `SmallVec` properties with a single check of the current storage variant.
#[inline]
fn triple(&self) -> (ConstNonNull<A::Item>, usize, usize) {
unsafe {
@@ -1055,13 +1051,12 @@ impl<A: Array> SmallVec<A> {
}
}
-
#[cfg(feature = "drain_filter")]
/// Creates an iterator which uses a closure to determine if an element should be removed.
- ///
+ ///
/// If the closure returns true, the element is removed and yielded. If the closure returns
/// false, the element will remain in the vector and will not be yielded by the iterator.
- ///
+ ///
/// Using this method is equivalent to the following code:
/// ```
/// # use smallvec::SmallVec;
@@ -1076,7 +1071,7 @@ impl<A: Array> SmallVec<A> {
/// i += 1;
/// }
/// }
- ///
+ ///
/// # assert_eq!(vec, SmallVec::<[i32; 8]>::from_slice(&[1i32, 4, 5]));
/// ```
/// ///
@@ -1476,7 +1471,7 @@ impl<A: Array> SmallVec<A> {
}
}
- /// Convert a SmallVec to a Vec, without reallocating if the SmallVec has already spilled onto
+ /// Convert a `SmallVec` to a `Vec`, without reallocating if the `SmallVec` has already spilled onto
/// the heap.
pub fn into_vec(mut self) -> Vec<A::Item> {
if self.spilled() {
@@ -1499,10 +1494,10 @@ impl<A: Array> SmallVec<A> {
self.into_vec().into_boxed_slice()
}
- /// Convert the SmallVec into an `A` if possible. Otherwise return `Err(Self)`.
+ /// Convert the `SmallVec` into an `A` if possible. Otherwise return `Err(Self)`.
///
- /// This method returns `Err(Self)` if the SmallVec is too short (and the `A` contains uninitialized elements),
- /// or if the SmallVec is too long (and all the elements were spilled to the heap).
+ /// This method returns `Err(Self)` if the `SmallVec` is too short (and the `A` contains uninitialized elements),
+ /// or if the `SmallVec` is too long (and all the elements were spilled to the heap).
pub fn into_inner(self) -> Result<A, Self> {
if self.spilled() || self.len() != A::size() {
// Note: A::size, not Self::inline_capacity
@@ -1596,7 +1591,7 @@ impl<A: Array> SmallVec<A> {
///
/// If `new_len` is greater than `len`, the `SmallVec` is extended by the difference, with each
/// additional slot filled with the result of calling the closure `f`. The return values from `f`
- //// will end up in the `SmallVec` in the order they have been generated.
+ /// will end up in the `SmallVec` in the order they have been generated.
///
/// If `new_len` is less than `len`, the `SmallVec` is simply truncated.
///
@@ -1604,7 +1599,7 @@ impl<A: Array> SmallVec<A> {
/// value, use `resize`. If you want to use the `Default` trait to generate values, you can pass
/// `Default::default()` as the second argument.
///
- /// Added for std::vec::Vec compatibility (added in Rust 1.33.0)
+ /// Added for `std::vec::Vec` compatibility (added in Rust 1.33.0)
///
/// ```
/// # use smallvec::{smallvec, SmallVec};
@@ -1667,8 +1662,7 @@ impl<A: Array> SmallVec<A> {
/// # Examples
///
/// ```
- /// # #[macro_use] extern crate smallvec;
- /// # use smallvec::SmallVec;
+ /// # use smallvec::{smallvec, SmallVec};
/// use std::mem;
/// use std::ptr;
///
@@ -2322,7 +2316,7 @@ impl<'a, A: Array> IntoIterator for &'a mut SmallVec<A> {
}
}
-/// Types that can be used as the backing store for a SmallVec
+/// Types that can be used as the backing store for a [`SmallVec`].
pub unsafe trait Array {
/// The type of the array's elements.
type Item;
@@ -2332,7 +2326,7 @@ pub unsafe trait Array {
/// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
///
-/// Copied from https://github.com/rust-lang/rust/pull/36355
+/// Copied from <https://github.com/rust-lang/rust/pull/36355>
struct SetLenOnDrop<'a> {
len: &'a mut usize,
local_len: usize,
@@ -2390,9 +2384,23 @@ impl<T, const N: usize> SmallVec<[T; N]> {
data: SmallVecData::from_const(MaybeUninit::new(items)),
}
}
+
+ /// Constructs a new `SmallVec` on the stack from an array without
+ /// copying elements. Also sets the length. The user is responsible
+ /// for ensuring that `len <= N`.
+ ///
+ /// This is a `const` version of [`SmallVec::from_buf_and_len_unchecked`] that is enabled by the feature `const_new`, with the limitation that it only works for arrays.
+ #[cfg_attr(docsrs, doc(cfg(feature = "const_new")))]
+ #[inline]
+ pub const unsafe fn from_const_with_len_unchecked(items: [T; N], len: usize) -> Self {
+ SmallVec {
+ capacity: len,
+ data: SmallVecData::from_const(MaybeUninit::new(items)),
+ }
+ }
}
-#[cfg(all(feature = "const_generics", not(doc)))]
+#[cfg(feature = "const_generics")]
#[cfg_attr(docsrs, doc(cfg(feature = "const_generics")))]
unsafe impl<T, const N: usize> Array for [T; N] {
type Item = T;
@@ -2402,7 +2410,7 @@ unsafe impl<T, const N: usize> Array for [T; N] {
}
}
-#[cfg(any(not(feature = "const_generics"), doc))]
+#[cfg(not(feature = "const_generics"))]
macro_rules! impl_array(
($($size:expr),+) => {
$(
@@ -2415,7 +2423,7 @@ macro_rules! impl_array(
}
);
-#[cfg(any(not(feature = "const_generics"), doc))]
+#[cfg(not(feature = "const_generics"))]
impl_array!(
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 36, 0x40, 0x60, 0x80, 0x100, 0x200, 0x400, 0x600, 0x800, 0x1000,
diff --git a/third_party/rust/smallvec/src/tests.rs b/third_party/rust/smallvec/src/tests.rs
index bb39ddeb31..3eab846bf2 100644
--- a/third_party/rust/smallvec/src/tests.rs
+++ b/third_party/rust/smallvec/src/tests.rs
@@ -72,13 +72,13 @@ pub fn test_double_spill() {
);
}
-/// https://github.com/servo/rust-smallvec/issues/4
+// https://github.com/servo/rust-smallvec/issues/4
#[test]
fn issue_4() {
SmallVec::<[Box<u32>; 2]>::new();
}
-/// https://github.com/servo/rust-smallvec/issues/5
+// https://github.com/servo/rust-smallvec/issues/5
#[test]
fn issue_5() {
assert!(Some(SmallVec::<[&u32; 2]>::new()).is_some());
@@ -833,12 +833,9 @@ fn test_write() {
}
#[cfg(feature = "serde")]
-extern crate bincode;
-
-#[cfg(feature = "serde")]
#[test]
fn test_serde() {
- use self::bincode::{config, deserialize};
+ use bincode::{config, deserialize};
let mut small_vec: SmallVec<[i32; 2]> = SmallVec::new();
small_vec.push(1);
let encoded = config().limit(100).serialize(&small_vec).unwrap();
@@ -925,6 +922,12 @@ fn const_new() {
assert_eq!(v.len(), 2);
assert_eq!(v[0], 1);
assert_eq!(v[1], 4);
+ let v = const_new_with_len();
+ assert_eq!(v.capacity(), 4);
+ assert_eq!(v.len(), 3);
+ assert_eq!(v[0], 2);
+ assert_eq!(v[1], 5);
+ assert_eq!(v[2], 7);
}
#[cfg(feature = "const_new")]
const fn const_new_inner() -> SmallVec<[i32; 4]> {
@@ -938,6 +941,12 @@ const fn const_new_inline_sized() -> SmallVec<[i32; 4]> {
const fn const_new_inline_args() -> SmallVec<[i32; 2]> {
crate::smallvec_inline![1, 4]
}
+#[cfg(feature = "const_new")]
+const fn const_new_with_len() -> SmallVec<[i32; 4]> {
+ unsafe {
+ SmallVec::<[i32; 4]>::from_const_with_len_unchecked([2, 5, 7, 0], 3)
+ }
+}
#[test]
fn empty_macro() {