diff --git a/Cargo.lock b/Cargo.lock index ddfacaaccdd0eb43eafc7633a855d12e3fa436fb..2c09d3bee7899bde2ca80bb26c2c69958a148f25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,7 +477,7 @@ dependencies = [ "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -732,7 +732,7 @@ name = "fallible" version = "0.0.1" dependencies = [ "hashglobe 0.1.0", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -863,7 +863,7 @@ dependencies = [ "parking_lot 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.20.0", "servo_arc 0.1.1", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "style_traits 0.0.1", ] @@ -1254,7 +1254,7 @@ dependencies = [ "selectors 0.20.0", "servo_arc 0.1.1", "smallbitvec 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1598,7 +1598,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1945,7 +1945,7 @@ dependencies = [ "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "servo_arc 0.1.1", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2037,7 +2037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "smallvec" -version = "0.6.5" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2131,7 +2131,7 @@ dependencies = [ "selectors 0.20.0", "servo_arc 0.1.1", "smallbitvec 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "style_derive 0.0.1", "style_traits 0.0.1", "thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2184,7 +2184,7 @@ dependencies = [ "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.20.0", "size_of_test 0.0.1", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "style 0.0.1", "style_traits 0.0.1", ] @@ -2655,7 +2655,7 @@ dependencies = [ "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "webrender_api 0.57.2", @@ -3016,7 +3016,7 @@ dependencies = [ "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9776d6b986f77b35c6cf846c11ad986ff128fe0b2b63a3628e3755e8d3102d" "checksum smallbitvec 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c63726029f0069f88467873e47f392575f28f9f16b72ac65465263db4b3a13c" -"checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" +"checksum smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "26df3bb03ca5eac2e64192b723d51f56c1b1e0860e7c766281f4598f181acdc8" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970" "checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423" diff --git a/servo/components/fallible/Cargo.toml b/servo/components/fallible/Cargo.toml index 7b5291304be1371503c9ad8d53ccb810af7299b1..176355acd38d52d310b1fac6501b2596a42e6f3d 100644 --- a/servo/components/fallible/Cargo.toml +++ b/servo/components/fallible/Cargo.toml @@ -10,7 +10,7 @@ name = "fallible" path = "lib.rs" [dependencies] -smallvec = { version = "0.6", features = ["std", "union"] } +smallvec = "0.6.2" hashglobe = { path = "../hashglobe" } # This crate effectively does nothing except if the `known_system_malloc` diff --git a/servo/components/malloc_size_of/Cargo.toml b/servo/components/malloc_size_of/Cargo.toml index 7ecb2d5942272236065dafaa8b44740240df8401..cd05b5d50c09bdd1427aef3a6bd6b49832bc077c 100644 --- a/servo/components/malloc_size_of/Cargo.toml +++ b/servo/components/malloc_size_of/Cargo.toml @@ -37,7 +37,7 @@ serde_bytes = { version = "0.10", optional = true } servo_arc = { path = "../servo_arc" } servo_channel = { path = "../channel", optional = true } smallbitvec = "2.1.0" -smallvec = { version = "0.6", features = ["std", "union"] } +smallvec = "0.6" string_cache = { version = "0.7", optional = true } thin-slice = "0.1.0" time = { version = "0.1.17", optional = true } diff --git a/servo/components/selectors/Cargo.toml b/servo/components/selectors/Cargo.toml index 76cb50bcf82ef034d929ab6e46ed25a7ce13d013..42f8985b51b61d58db8720419dbf444bb2a9b3bd 100644 --- a/servo/components/selectors/Cargo.toml +++ b/servo/components/selectors/Cargo.toml @@ -28,7 +28,7 @@ fxhash = "0.2" phf = "0.7.18" precomputed-hash = "0.1" servo_arc = { version = "0.1", path = "../servo_arc" } -smallvec = { version = "0.6", features = ["std", "union"] } +smallvec = "0.6.2" thin-slice = "0.1.0" [build-dependencies] diff --git a/servo/components/style/Cargo.toml b/servo/components/style/Cargo.toml index c52d60a39360925622ea7605a884cad0a90832bb..9e0db8c3c2f43b88ca8cffbe9b598d4d486b383d 100644 --- a/servo/components/style/Cargo.toml +++ b/servo/components/style/Cargo.toml @@ -63,7 +63,7 @@ servo_atoms = {path = "../atoms", optional = true} servo_channel = {path = "../channel", optional = true} servo_config = {path = "../config", optional = true} smallbitvec = "2.1.1" -smallvec = { version = "0.6", features = ["std", "union"] } +smallvec = "0.6.2" string_cache = { version = "0.7", optional = true } style_derive = {path = "../style_derive"} style_traits = {path = "../style_traits"} diff --git a/third_party/rust/smallvec/.cargo-checksum.json b/third_party/rust/smallvec/.cargo-checksum.json index 518caa798e8fdee3af5b1c9489d6222cb500512a..5327b0f784a17d2dc73794cce8ba0b40abedc170 100644 --- a/third_party/rust/smallvec/.cargo-checksum.json +++ b/third_party/rust/smallvec/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".travis.yml":"106d159f3fbe3ad49ebc631f9707baedf6adb012e5210443919232db5375fa7b","Cargo.toml":"7d0640e384cf1d81593bd049f6bf5b1dcf129db200f4f21b18c06b6bdb5d67a3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0b28172679e0009b655da42797c03fd163a3379d5cfa67ba1f1655e974a2a1a9","README.md":"1bc64a621160a291c86b8770f3eeaa45a31c31d91c2a071f39981c14fdacb035","benches/bench.rs":"9dca7122a3dcb2c099e49807e4d3b8f01d9220e2b3db0a54e9901ee74392866f","lib.rs":"513374844e0fc3bc332f5172de3a604acab160e02f576f7d9eaebe64149588a9"},"package":"153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d"} \ No newline at end of file +{"files":{".travis.yml":"1fb562c82e3ba8668667016eb5be043130a943a3e22c2c692dfcefd23bb07028","Cargo.toml":"2f8fa5e2e7894727dab3b256f93c739ee2fdd715cad0ea18b466330325dc6c90","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0b28172679e0009b655da42797c03fd163a3379d5cfa67ba1f1655e974a2a1a9","README.md":"1bc64a621160a291c86b8770f3eeaa45a31c31d91c2a071f39981c14fdacb035","benches/bench.rs":"bf8c9a06dad072e14e844daf43895c41d632db183f33fa6de53a43d3677a7375","lib.rs":"dd8993f008a5512d33a74d5e141a4d9d6294baa11174bfeeec2251d731d51957"},"package":"26df3bb03ca5eac2e64192b723d51f56c1b1e0860e7c766281f4598f181acdc8"} \ No newline at end of file diff --git a/third_party/rust/smallvec/.travis.yml b/third_party/rust/smallvec/.travis.yml index b45c7f81be1879cacfca2618b4303ced98789f91..93256e29c5b7c9e998a5571a86c9dfab11f50de7 100644 --- a/third_party/rust/smallvec/.travis.yml +++ b/third_party/rust/smallvec/.travis.yml @@ -1,16 +1,13 @@ language: rust rust: - - 1.20.0 - nightly - beta - stable script: | cargo build --verbose && cargo test --verbose && - cargo test --verbose --features serde && ([ $TRAVIS_RUST_VERSION != nightly ] || cargo check --verbose --no-default-features) && ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --features union) && - ([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --all-features) && ([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose bench) notifications: webhooks: http://build.servo.org:54856/travis diff --git a/third_party/rust/smallvec/Cargo.toml b/third_party/rust/smallvec/Cargo.toml index 4600cdbd4ebea77a83288d9cc4c3be430c7251d8..9e7bb4628bfe4351ab07a8d58e3ca1de4199ac49 100644 --- a/third_party/rust/smallvec/Cargo.toml +++ b/third_party/rust/smallvec/Cargo.toml @@ -12,7 +12,7 @@ [package] name = "smallvec" -version = "0.6.5" +version = "0.6.3" authors = ["Simon Sapin <simon.sapin@exyr.org>"] description = "'Small vector' optimization: store up to a small number of items on the stack" documentation = "http://doc.servo.org/smallvec/" diff --git a/third_party/rust/smallvec/benches/bench.rs b/third_party/rust/smallvec/benches/bench.rs index 36cb1333fab7a834bb3e645b7c5234743b54c951..c439bec6dabe2abcaa99ea729ca09a3b126d788c 100644 --- a/third_party/rust/smallvec/benches/bench.rs +++ b/third_party/rust/smallvec/benches/bench.rs @@ -17,7 +17,6 @@ trait Vector<T>: for<'a> From<&'a [T]> + Extend<T> + ExtendFromSlice<T> { fn remove(&mut self, p: usize) -> T; fn insert(&mut self, n: usize, val: T); fn from_elem(val: T, n: usize) -> Self; - fn from_elems(val: &[T]) -> Self; } impl<T: Copy> Vector<T> for Vec<T> { @@ -44,10 +43,6 @@ impl<T: Copy> Vector<T> for Vec<T> { fn from_elem(val: T, n: usize) -> Self { vec![val; n] } - - fn from_elems(val: &[T]) -> Self { - val.to_owned() - } } impl<T: Copy> Vector<T> for SmallVec<[T; VEC_SIZE]> { @@ -74,10 +69,6 @@ impl<T: Copy> Vector<T> for SmallVec<[T; VEC_SIZE]> { fn from_elem(val: T, n: usize) -> Self { smallvec![val; n] } - - fn from_elems(val: &[T]) -> Self { - SmallVec::from_slice(val) - } } macro_rules! make_benches { @@ -101,8 +92,6 @@ make_benches! { bench_remove_small => gen_remove(VEC_SIZE as _), bench_extend => gen_extend(SPILLED_SIZE as _), bench_extend_small => gen_extend(VEC_SIZE as _), - bench_from_iter => gen_from_iter(SPILLED_SIZE as _), - bench_from_iter_small => gen_from_iter(VEC_SIZE as _), bench_from_slice => gen_from_slice(SPILLED_SIZE as _), bench_from_slice_small => gen_from_slice(VEC_SIZE as _), bench_extend_from_slice => gen_extend_from_slice(SPILLED_SIZE as _), @@ -123,8 +112,6 @@ make_benches! { bench_remove_vec_small => gen_remove(VEC_SIZE as _), bench_extend_vec => gen_extend(SPILLED_SIZE as _), bench_extend_vec_small => gen_extend(VEC_SIZE as _), - bench_from_iter_vec => gen_from_iter(SPILLED_SIZE as _), - bench_from_iter_vec_small => gen_from_iter(VEC_SIZE as _), bench_from_slice_vec => gen_from_slice(SPILLED_SIZE as _), bench_from_slice_vec_small => gen_from_slice(VEC_SIZE as _), bench_extend_from_slice_vec => gen_extend_from_slice(SPILLED_SIZE as _), @@ -192,18 +179,10 @@ fn gen_extend<V: Vector<u64>>(n: u64, b: &mut Bencher) { }); } -fn gen_from_iter<V: Vector<u64>>(n: u64, b: &mut Bencher) { - let v: Vec<u64> = (0..n).collect(); - b.iter(|| { - let vec = V::from(&v); - vec - }); -} - fn gen_from_slice<V: Vector<u64>>(n: u64, b: &mut Bencher) { let v: Vec<u64> = (0..n).collect(); b.iter(|| { - let vec = V::from_elems(&v); + let vec = V::from(&v); vec }); } diff --git a/third_party/rust/smallvec/lib.rs b/third_party/rust/smallvec/lib.rs index 881021e14c27108c5ae8e45afd51ba8f219468b9..6b302fdee277c9c5a26bf5ac4413146505e49503 100644 --- a/third_party/rust/smallvec/lib.rs +++ b/third_party/rust/smallvec/lib.rs @@ -113,20 +113,11 @@ use std::marker::PhantomData; #[macro_export] macro_rules! smallvec { - // count helper: transform any expression into 1 - (@one $x:expr) => (1usize); ($elem:expr; $n:expr) => ({ - $crate::SmallVec::from_elem($elem, $n) + SmallVec::from_elem($elem, $n) }); ($($x:expr),*$(,)*) => ({ - let count = 0usize $(+ smallvec!(@one $x))*; - let mut vec = $crate::SmallVec::new(); - if count <= vec.inline_size() { - $(vec.push($x);)* - vec - } else { - $crate::SmallVec::from_vec(vec![$($x,)*]) - } + SmallVec::from_slice(&[$($x),*]) }); } @@ -240,7 +231,14 @@ impl<'a, T: 'a> Iterator for Drain<'a,T> { #[inline] fn next(&mut self) -> Option<T> { - self.iter.next().map(|reference| unsafe { ptr::read(reference) }) + match self.iter.next() { + None => None, + Some(reference) => { + unsafe { + Some(ptr::read(reference)) + } + } + } } #[inline] @@ -252,7 +250,14 @@ impl<'a, T: 'a> Iterator for Drain<'a,T> { impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> { #[inline] fn next_back(&mut self) -> Option<T> { - self.iter.next_back().map(|reference| unsafe { ptr::read(reference) }) + match self.iter.next_back() { + None => None, + Some(reference) => { + unsafe { + Some(ptr::read(reference)) + } + } + } } } @@ -287,8 +292,6 @@ impl<A: Array> SmallVecData<A> { SmallVecData { inline } } #[inline] - unsafe fn into_inline(self) -> A { self.inline } - #[inline] unsafe fn heap(&self) -> (*mut A::Item, usize) { self.heap } @@ -329,13 +332,6 @@ impl<A: Array> SmallVecData<A> { SmallVecData::Inline(ManuallyDrop::new(inline)) } #[inline] - unsafe fn into_inline(self) -> A { - match self { - SmallVecData::Inline(a) => ManuallyDrop::into_inner(a), - _ => debug_unreachable!(), - } - } - #[inline] unsafe fn heap(&self) -> (*mut A::Item, usize) { match *self { SmallVecData::Heap(data) => data, @@ -480,47 +476,6 @@ impl<A: Array> SmallVec<A> { } } - /// Constructs a new `SmallVec` on the stack from an `A` without - /// copying elements. Also sets the length, which must be less or - /// equal to the size of `buf`. - /// - /// ```rust - /// use smallvec::SmallVec; - /// - /// let buf = [1, 2, 3, 4, 5, 0, 0, 0]; - /// let small_vec: SmallVec<_> = SmallVec::from_buf_and_len(buf, 5); - /// - /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); - /// ``` - #[inline] - pub fn from_buf_and_len(buf: A, len: usize) -> SmallVec<A> { - assert!(len <= A::size()); - unsafe { SmallVec::from_buf_and_len_unchecked(buf, len) } - } - - /// Constructs a new `SmallVec` on the stack from an `A` without - /// copying elements. Also sets the length. The user is responsible - /// for ensuring that `len <= A::size()`. - /// - /// ```rust - /// use smallvec::SmallVec; - /// - /// let buf = [1, 2, 3, 4, 5, 0, 0, 0]; - /// let small_vec: SmallVec<_> = unsafe { - /// SmallVec::from_buf_and_len_unchecked(buf, 5) - /// }; - /// - /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]); - /// ``` - #[inline] - pub unsafe fn from_buf_and_len_unchecked(buf: A, len: usize) -> SmallVec<A> { - SmallVec { - capacity: len, - data: SmallVecData::from_inline(buf), - } - } - - /// Sets the length of a vector. /// /// This will explicitly set the size of the vector, without actually @@ -610,7 +565,7 @@ impl<A: Array> SmallVec<A> { unsafe { let (_, &mut len, cap) = self.triple_mut(); if len == cap { - self.reserve(1); + self.grow(cmp::max(cap * 2, 1)) } let (ptr, len_ptr, _) = self.triple_mut(); *len_ptr = len + 1; @@ -638,14 +593,15 @@ impl<A: Array> SmallVec<A> { pub fn grow(&mut self, new_cap: usize) { unsafe { let (ptr, &mut len, cap) = self.triple_mut(); - let unspilled = !self.spilled(); + let spilled = self.spilled(); assert!(new_cap >= len); if new_cap <= self.inline_size() { - if unspilled { + if !spilled { return; } self.data = SmallVecData::from_inline(mem::uninitialized()); ptr::copy_nonoverlapping(ptr, self.data.inline_mut().ptr_mut(), len); + deallocate(ptr, cap); } else if new_cap != cap { let mut vec = Vec::with_capacity(new_cap); let new_alloc = vec.as_mut_ptr(); @@ -653,11 +609,10 @@ impl<A: Array> SmallVec<A> { ptr::copy_nonoverlapping(ptr, new_alloc, len); self.data = SmallVecData::from_heap(new_alloc, len); self.capacity = new_cap; - if unspilled { - return; + if spilled { + deallocate(ptr, cap); } } - deallocate(ptr, cap); } } @@ -668,7 +623,6 @@ impl<A: Array> SmallVec<A> { /// If the new capacity would overflow `usize` then it will be set to `usize::max_value()` /// instead. (This means that inserting `additional` new elements is not guaranteed to be /// possible after calling this function.) - #[inline] pub fn reserve(&mut self, additional: usize) { // prefer triple_mut() even if triple() would work // so that the optimizer removes duplicated calls to it @@ -862,22 +816,6 @@ impl<A: Array> SmallVec<A> { } } - /// 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). - pub fn into_inner(self) -> Result<A, Self> { - if self.spilled() || self.len() != A::size() { - Err(self) - } else { - unsafe { - let data = ptr::read(&self.data); - mem::forget(self); - Ok(data.into_inline()) - } - } - } - /// Retains only the elements specified by the predicate. /// /// In other words, remove all elements `e` such that `f(&e)` returns `false`. @@ -946,25 +884,9 @@ impl<A: Array> SmallVec<A> where A::Item: Copy { /// /// For slices of `Copy` types, this is more efficient than `SmallVec::from(slice)`. pub fn from_slice(slice: &[A::Item]) -> Self { - let len = slice.len(); - if len <= A::size() { - SmallVec { - capacity: len, - data: SmallVecData::from_inline(unsafe { - let mut data: A = mem::uninitialized(); - ptr::copy_nonoverlapping(slice.as_ptr(), data.ptr_mut(), len); - data - }) - } - } else { - let mut b = slice.to_vec(); - let ptr = b.as_mut_ptr(); - mem::forget(b); - SmallVec { - capacity: len, - data: SmallVecData::from_heap(ptr, len), - } - } + let mut vec = Self::new(); + vec.extend_from_slice(slice); + vec } /// Copy elements from a slice into the vector at position `index`, shifting any following @@ -1253,7 +1175,7 @@ impl<A: Array> Extend<A::Item> for SmallVec<A> { impl<A: Array> fmt::Debug for SmallVec<A> where A::Item: fmt::Debug { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_list().entries(self.iter()).finish() + write!(f, "{:?}", &**self) } } @@ -1757,7 +1679,6 @@ mod tests { assert_eq!(&v.iter().map(|v| *v).collect::<Vec<_>>(), &[0, 5, 6, 1, 2, 3]); } - #[cfg(feature = "std")] #[test] // https://github.com/servo/rust-smallvec/issues/96 fn test_insert_many_panic() { @@ -2028,18 +1949,6 @@ mod tests { assert_eq!(vec.into_vec(), vec![0, 1, 2]); } - #[test] - fn test_into_inner() { - let vec = SmallVec::<[u8; 2]>::from_iter(0..2); - assert_eq!(vec.into_inner(), Ok([0, 1])); - - let vec = SmallVec::<[u8; 2]>::from_iter(0..1); - assert_eq!(vec.clone().into_inner(), Err(vec)); - - let vec = SmallVec::<[u8; 2]>::from_iter(0..3); - assert_eq!(vec.clone().into_inner(), Err(vec)); - } - #[test] fn test_from_vec() { let vec = vec![]; @@ -2161,10 +2070,10 @@ mod tests { #[cfg(feature = "serde")] #[test] fn test_serde() { - use self::bincode::{config, deserialize}; + use self::bincode::{serialize, deserialize, Bounded}; let mut small_vec: SmallVec<[i32; 2]> = SmallVec::new(); small_vec.push(1); - let encoded = config().limit(100).serialize(&small_vec).unwrap(); + let encoded = serialize(&small_vec, Bounded(100)).unwrap(); let decoded: SmallVec<[i32; 2]> = deserialize(&encoded).unwrap(); assert_eq!(small_vec, decoded); small_vec.push(2); @@ -2172,7 +2081,7 @@ mod tests { small_vec.push(3); small_vec.push(4); // Check again after spilling. - let encoded = config().limit(100).serialize(&small_vec).unwrap(); + let encoded = serialize(&small_vec, Bounded(100)).unwrap(); let decoded: SmallVec<[i32; 2]> = deserialize(&encoded).unwrap(); assert_eq!(small_vec, decoded); }