diff options
Diffstat (limited to 'vendor/smallvec')
-rw-r--r-- | vendor/smallvec/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/smallvec/Cargo.toml | 3 | ||||
-rw-r--r-- | vendor/smallvec/benches/bench.rs | 4 | ||||
-rw-r--r-- | vendor/smallvec/src/lib.rs | 81 | ||||
-rw-r--r-- | vendor/smallvec/src/tests.rs | 9 |
5 files changed, 52 insertions, 47 deletions
diff --git a/vendor/smallvec/.cargo-checksum.json b/vendor/smallvec/.cargo-checksum.json index 3dd42db31..563316cb8 100644 --- a/vendor/smallvec/.cargo-checksum.json +++ b/vendor/smallvec/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"dd059cc04554e412d3ad325d3cbbd5bfd275428fea1f7930c9b2aaf87c2dcab8","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":"f2f20a3dffbde2514044e43626d4d3da73d15e2cbed7cdcc65f310373dd7fae9","src/specialization.rs":"46433586203399251cba496d67b88d34e1be3c2b591986b77463513da1c66471","src/tests.rs":"d0a70bb7b4e1d0a174f2a195c8ab55280a40589bab7028999afd787b3fff6eae","tests/debugger_visualizer.rs":"185456ad253957fc0c9e904ff8a1135397ac991c29fa3c60f75d8d81f7463022","tests/macro.rs":"22ad4f6f104a599fdcba19cad8834105b8656b212fb6c7573a427d447f5db14f"},"package":"62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"}
\ No newline at end of file +{"files":{"Cargo.toml":"12129d19d241f8b8041854ed140f6bdfb05ec43742d0f80779e40b1b24365c79","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":"fbae23a885178a0a8e1372e81e85fd9d65f4416f53ab489b1bde65854396ff48","src/specialization.rs":"46433586203399251cba496d67b88d34e1be3c2b591986b77463513da1c66471","src/tests.rs":"11c951cb4da40e13de1f7058e023cd29e857216e1e3243111a63ae79e931dbc6","tests/debugger_visualizer.rs":"185456ad253957fc0c9e904ff8a1135397ac991c29fa3c60f75d8d81f7463022","tests/macro.rs":"22ad4f6f104a599fdcba19cad8834105b8656b212fb6c7573a427d447f5db14f"},"package":"4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"}
\ No newline at end of file diff --git a/vendor/smallvec/Cargo.toml b/vendor/smallvec/Cargo.toml index 7d3e21640..d85fba766 100644 --- a/vendor/smallvec/Cargo.toml +++ b/vendor/smallvec/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "smallvec" -version = "1.11.0" +version = "1.11.2" 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/" @@ -33,6 +33,7 @@ all-features = true rustdoc-args = [ "--cfg", "docsrs", + "--generate-link-to-definition", ] [[test]] diff --git a/vendor/smallvec/benches/bench.rs b/vendor/smallvec/benches/bench.rs index b52ee1550..b6a8b857d 100644 --- a/vendor/smallvec/benches/bench.rs +++ b/vendor/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/vendor/smallvec/src/lib.rs b/vendor/smallvec/src/lib.rs index fa3d8ca03..f9a6c8a1a 100644 --- a/vendor/smallvec/src/lib.rs +++ b/vendor/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])); /// ``` /// /// @@ -1120,7 +1115,7 @@ impl<A: Array> SmallVec<A> { unsafe { let (mut ptr, mut len, cap) = self.triple_mut(); if *len == cap { - self.reserve(1); + self.reserve_one_unchecked(); let (heap_ptr, heap_len) = self.data.heap_mut(); ptr = heap_ptr; len = heap_len; @@ -1225,13 +1220,23 @@ impl<A: Array> SmallVec<A> { infallible(self.try_reserve(additional)) } + /// Internal method used to grow in push() and insert(), where we know already we have to grow. + #[cold] + fn reserve_one_unchecked(&mut self) { + debug_assert_eq!(self.len(), self.capacity()); + let new_cap = self.len() + .checked_add(1) + .and_then(usize::checked_next_power_of_two) + .expect("capacity overflow"); + infallible(self.try_grow(new_cap)) + } + /// Reserve capacity for `additional` more elements to be inserted. /// /// May reserve more space to avoid frequent reallocations. pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> { - // prefer triple_mut() even if triple() would work - // so that the optimizer removes duplicated calls to it - // from callers like insert() + // prefer triple_mut() even if triple() would work so that the optimizer removes duplicated + // calls to it from callers. let (_, &mut len, cap) = self.triple_mut(); if cap - len >= additional { return Ok(()); @@ -1357,10 +1362,14 @@ impl<A: Array> SmallVec<A> { /// /// Panics if `index > len`. pub fn insert(&mut self, index: usize, element: A::Item) { - self.reserve(1); - unsafe { - let (ptr, len_ptr, _) = self.triple_mut(); + let (mut ptr, mut len_ptr, cap) = self.triple_mut(); + if *len_ptr == cap { + self.reserve_one_unchecked(); + let (heap_ptr, heap_len_ptr) = self.data.heap_mut(); + ptr = heap_ptr; + len_ptr = heap_len_ptr; + } let mut ptr = ptr.as_ptr(); let len = *len_ptr; ptr = ptr.add(index); @@ -1462,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() { @@ -1485,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 @@ -1582,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. /// @@ -1590,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}; @@ -1653,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; /// @@ -1758,6 +1766,7 @@ where /// elements toward the back. /// /// For slices of `Copy` types, this is more efficient than `insert`. + #[inline] pub fn insert_from_slice(&mut self, index: usize, slice: &[A::Item]) { self.reserve(slice.len()); @@ -2307,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; @@ -2317,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, @@ -2377,7 +2386,7 @@ impl<T, const N: usize> SmallVec<[T; N]> { } } -#[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; @@ -2387,7 +2396,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),+) => { $( @@ -2400,7 +2409,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/vendor/smallvec/src/tests.rs b/vendor/smallvec/src/tests.rs index bb39ddeb3..936ad6f5e 100644 --- a/vendor/smallvec/src/tests.rs +++ b/vendor/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(); |