summaryrefslogtreecommitdiffstats
path: root/vendor/arrayvec
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/arrayvec')
-rw-r--r--vendor/arrayvec/.cargo-checksum.json2
-rw-r--r--vendor/arrayvec/CHANGELOG.md12
-rw-r--r--vendor/arrayvec/Cargo.toml34
-rw-r--r--vendor/arrayvec/LICENSE-MIT2
-rwxr-xr-xvendor/arrayvec/ci/miri.sh15
-rw-r--r--vendor/arrayvec/src/array_string.rs41
-rw-r--r--vendor/arrayvec/src/arrayvec.rs43
-rw-r--r--vendor/arrayvec/src/arrayvec_impl.rs1
-rw-r--r--vendor/arrayvec/src/lib.rs4
9 files changed, 122 insertions, 32 deletions
diff --git a/vendor/arrayvec/.cargo-checksum.json b/vendor/arrayvec/.cargo-checksum.json
index d0de9348c..f7b6795ac 100644
--- a/vendor/arrayvec/.cargo-checksum.json
+++ b/vendor/arrayvec/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"f684ba712e1546b4cc7de9637f484598cd3fa49b7e7b32c2d98562a8f78ce98c","Cargo.toml":"94a588809d4be252f0146b9e193abc1b22d8afcce0265af19f12905a3db37998","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0245ee104228a100ce5fceecf43e25faae450494d9173f43fd94c27d69fdac13","README.md":"2264c34c62ea4c617d72047b00749b4786dfb9dff2fac24e0320170ee0cd19c8","benches/arraystring.rs":"fad1cecef71c290375befc77c75a868988b8d74135e8f8732bc5b58c85a8ab46","benches/extend.rs":"c38ecedbc88217a7e9fe1a73f916b168a96e48010a7ccd3dba5c3f8dea030d5d","ci/miri.sh":"6bad1d135e1bdd67a6b91c870a7cf5ee09a85f9515633592a6abfbba95fdaf52","src/array_string.rs":"4f0c2dab882e6df7d10a0b043220587626e64ff94dd53a80949667ed861490de","src/arrayvec.rs":"61fba79217f564e54761c25651c06ec3f6d23b9c6af4bfd621992ef2bb95a74b","src/arrayvec_impl.rs":"a5e3391dc350041651f0ba3816c863ff7f552ff553e4a88f801481dfad7e7613","src/char.rs":"1de50e1d6045af2b3496426492315ba774986f9bc8301ffa391de861a08cc9cb","src/errors.rs":"7fa2ff2350f811d52a210a7346c526d6715cacefd38a46e2d3b57ab7dc62b1ab","src/lib.rs":"29a4123616c0912ccae5d931d45f0ccc3746647da1ba077c34538824910dd0ca","src/utils.rs":"d1cdc508dfca385e63f1f57bc8b53ed4a7f515e4ac1ebaa97b1d543fc8369432","tests/serde.rs":"117eb2961b5954d13c577edf60bbb07cb7481685cc9d6c49760a981d71465849","tests/tests.rs":"f8a18ff5deadb167832964ca0fff4f280129dd4a1de024e9cc76ffb7efe1c12c"},"package":"8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"fc3afac61cfb6ed0370d35d8b7a01a9a4c43f07080ca6d7f4ed0ec5ffa1938a5","Cargo.toml":"bc1eb1e01f42009ada105cdcf8210471c9f988274a8e3874a362d169e90673dd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"4da95ec4ecb65b738d470b7d762894ad9c97da93e6cbfb18b570fc2c96f4b871","README.md":"2264c34c62ea4c617d72047b00749b4786dfb9dff2fac24e0320170ee0cd19c8","benches/arraystring.rs":"fad1cecef71c290375befc77c75a868988b8d74135e8f8732bc5b58c85a8ab46","benches/extend.rs":"c38ecedbc88217a7e9fe1a73f916b168a96e48010a7ccd3dba5c3f8dea030d5d","src/array_string.rs":"39d9c33cdd3ec76e3dfd81996872c58d720877ef93fa7e8b23985d266230a2d6","src/arrayvec.rs":"50e2097cdfa4f1477c925daaf53cc7d59b31c66d11c0766cc1cbf14dad9dbc98","src/arrayvec_impl.rs":"e2642ae566c83ef37ad9aec6af7e3c50af310ba304553f38b2a787666b507580","src/char.rs":"1de50e1d6045af2b3496426492315ba774986f9bc8301ffa391de861a08cc9cb","src/errors.rs":"7fa2ff2350f811d52a210a7346c526d6715cacefd38a46e2d3b57ab7dc62b1ab","src/lib.rs":"8919a7e0c20890b1f094996147a1486d20578579aef03692315cd509e1745222","src/utils.rs":"d1cdc508dfca385e63f1f57bc8b53ed4a7f515e4ac1ebaa97b1d543fc8369432","tests/serde.rs":"117eb2961b5954d13c577edf60bbb07cb7481685cc9d6c49760a981d71465849","tests/tests.rs":"f8a18ff5deadb167832964ca0fff4f280129dd4a1de024e9cc76ffb7efe1c12c"},"package":"96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"} \ No newline at end of file
diff --git a/vendor/arrayvec/CHANGELOG.md b/vendor/arrayvec/CHANGELOG.md
index 903ef582f..40a646a09 100644
--- a/vendor/arrayvec/CHANGELOG.md
+++ b/vendor/arrayvec/CHANGELOG.md
@@ -1,6 +1,18 @@
Recent Changes (arrayvec)
=========================
+## 0.7.4
+
+- Add feature zeroize to support the `Zeroize` trait by @elichai
+
+## 0.7.3
+
+- Use track_caller on multiple methods like push and similar, for capacity
+ overflows by @kornelski
+- impl BorrowMut for ArrayString by @msrd0
+- Fix stacked borrows violations by @clubby789
+- Update Miri CI by @RalfJung
+
## 0.7.2
- Add `.as_mut_str()` to `ArrayString` by @clarfonthey
diff --git a/vendor/arrayvec/Cargo.toml b/vendor/arrayvec/Cargo.toml
index 54b00740c..308c6b2df 100644
--- a/vendor/arrayvec/Cargo.toml
+++ b/vendor/arrayvec/Cargo.toml
@@ -12,25 +12,40 @@
[package]
edition = "2018"
name = "arrayvec"
-version = "0.7.2"
+version = "0.7.4"
authors = ["bluss"]
description = "A vector with fixed capacity, backed by an array (it can be stored on the stack too). Implements fixed capacity ArrayVec and ArrayString."
documentation = "https://docs.rs/arrayvec/"
-keywords = ["stack", "vector", "array", "data-structure", "no_std"]
-categories = ["data-structures", "no-std"]
+readme = "README.md"
+keywords = [
+ "stack",
+ "vector",
+ "array",
+ "data-structure",
+ "no_std",
+]
+categories = [
+ "data-structures",
+ "no-std",
+]
license = "MIT OR Apache-2.0"
repository = "https://github.com/bluss/arrayvec"
+
[package.metadata.docs.rs]
-features = ["serde"]
+features = [
+ "serde",
+ "zeroize",
+]
[package.metadata.release]
no-dev-version = true
tag-name = "{{version}}"
+
[profile.bench]
-debug = true
+debug = 2
[profile.release]
-debug = true
+debug = 2
[[bench]]
name = "extend"
@@ -39,10 +54,17 @@ harness = false
[[bench]]
name = "arraystring"
harness = false
+
[dependencies.serde]
version = "1.0"
optional = true
default-features = false
+
+[dependencies.zeroize]
+version = "1.4"
+optional = true
+default-features = false
+
[dev-dependencies.bencher]
version = "0.1.4"
diff --git a/vendor/arrayvec/LICENSE-MIT b/vendor/arrayvec/LICENSE-MIT
index 2c8f27dba..db4c06734 100644
--- a/vendor/arrayvec/LICENSE-MIT
+++ b/vendor/arrayvec/LICENSE-MIT
@@ -1,4 +1,4 @@
-Copyright (c) Ulrik Sverdrup "bluss" 2015-2017
+Copyright (c) Ulrik Sverdrup "bluss" 2015-2023
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
diff --git a/vendor/arrayvec/ci/miri.sh b/vendor/arrayvec/ci/miri.sh
deleted file mode 100755
index 272995ca8..000000000
--- a/vendor/arrayvec/ci/miri.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-set -ex
-
-export CARGO_NET_RETRY=5
-export CARGO_NET_TIMEOUT=10
-
-MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
-echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
-rustup default "$MIRI_NIGHTLY"
-
-rustup component add miri
-cargo miri setup
-
-cargo miri test
diff --git a/vendor/arrayvec/src/array_string.rs b/vendor/arrayvec/src/array_string.rs
index c4712a0cb..90cfc0901 100644
--- a/vendor/arrayvec/src/array_string.rs
+++ b/vendor/arrayvec/src/array_string.rs
@@ -1,4 +1,4 @@
-use std::borrow::Borrow;
+use std::borrow::{Borrow, BorrowMut};
use std::cmp;
use std::convert::TryFrom;
use std::fmt;
@@ -201,6 +201,7 @@ impl<const CAP: usize> ArrayString<CAP>
///
/// assert_eq!(&string[..], "ab");
/// ```
+ #[track_caller]
pub fn push(&mut self, c: char) {
self.try_push(c).unwrap();
}
@@ -252,6 +253,7 @@ impl<const CAP: usize> ArrayString<CAP>
///
/// assert_eq!(&string[..], "ad");
/// ```
+ #[track_caller]
pub fn push_str(&mut self, s: &str) {
self.try_push_str(s).unwrap()
}
@@ -371,10 +373,12 @@ impl<const CAP: usize> ArrayString<CAP>
let next = idx + ch.len_utf8();
let len = self.len();
+ let ptr = self.as_mut_ptr();
unsafe {
- ptr::copy(self.as_ptr().add(next),
- self.as_mut_ptr().add(idx),
- len - next);
+ ptr::copy(
+ ptr.add(next),
+ ptr.add(idx),
+ len - next);
self.set_len(len - (next - idx));
}
ch
@@ -479,6 +483,11 @@ impl<const CAP: usize> Borrow<str> for ArrayString<CAP>
fn borrow(&self) -> &str { self }
}
+impl<const CAP: usize> BorrowMut<str> for ArrayString<CAP>
+{
+ fn borrow_mut(&mut self) -> &mut str { self }
+}
+
impl<const CAP: usize> AsRef<str> for ArrayString<CAP>
{
fn as_ref(&self) -> &str { self }
@@ -638,3 +647,27 @@ impl<'a, const CAP: usize> TryFrom<fmt::Arguments<'a>> for ArrayString<CAP>
Ok(v)
}
}
+
+#[cfg(feature = "zeroize")]
+/// "Best efforts" zeroing of the `ArrayString`'s buffer when the `zeroize` feature is enabled.
+///
+/// The length is set to 0, and the buffer is dropped and zeroized.
+/// Cannot ensure that previous moves of the `ArrayString` did not leave values on the stack.
+///
+/// ```
+/// use arrayvec::ArrayString;
+/// use zeroize::Zeroize;
+/// let mut string = ArrayString::<6>::from("foobar").unwrap();
+/// string.zeroize();
+/// assert_eq!(string.len(), 0);
+/// unsafe { string.set_len(string.capacity()) };
+/// assert_eq!(&*string, "\0\0\0\0\0\0");
+/// ```
+impl<const CAP: usize> zeroize::Zeroize for ArrayString<CAP> {
+ fn zeroize(&mut self) {
+ // There are no elements to drop
+ self.clear();
+ // Zeroize the backing array.
+ self.xs.zeroize();
+ }
+}
diff --git a/vendor/arrayvec/src/arrayvec.rs b/vendor/arrayvec/src/arrayvec.rs
index e69e60c18..37e151a6b 100644
--- a/vendor/arrayvec/src/arrayvec.rs
+++ b/vendor/arrayvec/src/arrayvec.rs
@@ -77,6 +77,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
/// assert_eq!(&array[..], &[1, 2]);
/// assert_eq!(array.capacity(), 16);
/// ```
+ #[inline]
+ #[track_caller]
pub fn new() -> ArrayVec<T, CAP> {
assert_capacity_limit!(CAP);
unsafe {
@@ -172,6 +174,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
///
/// assert_eq!(&array[..], &[1, 2]);
/// ```
+ #[track_caller]
pub fn push(&mut self, element: T) {
ArrayVecImpl::push(self, element)
}
@@ -277,6 +280,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
/// assert_eq!(&array[..], &["y", "x"]);
///
/// ```
+ #[track_caller]
pub fn insert(&mut self, index: usize, element: T) {
self.try_insert(index, element).unwrap()
}
@@ -507,7 +511,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
}
if DELETED {
unsafe {
- let hole_slot = g.v.as_mut_ptr().add(g.processed_len - g.deleted_cnt);
+ let hole_slot = cur.sub(g.deleted_cnt);
ptr::copy_nonoverlapping(cur, hole_slot, 1);
}
}
@@ -748,6 +752,7 @@ impl<T, const CAP: usize> DerefMut for ArrayVec<T, CAP> {
/// assert_eq!(array.capacity(), 3);
/// ```
impl<T, const CAP: usize> From<[T; CAP]> for ArrayVec<T, CAP> {
+ #[track_caller]
fn from(array: [T; CAP]) -> Self {
let array = ManuallyDrop::new(array);
let mut vec = <ArrayVec<T, CAP>>::new();
@@ -843,6 +848,32 @@ impl<T, const CAP: usize> IntoIterator for ArrayVec<T, CAP> {
}
+#[cfg(feature = "zeroize")]
+/// "Best efforts" zeroing of the `ArrayVec`'s buffer when the `zeroize` feature is enabled.
+///
+/// The length is set to 0, and the buffer is dropped and zeroized.
+/// Cannot ensure that previous moves of the `ArrayVec` did not leave values on the stack.
+///
+/// ```
+/// use arrayvec::ArrayVec;
+/// use zeroize::Zeroize;
+/// let mut array = ArrayVec::from([1, 2, 3]);
+/// array.zeroize();
+/// assert_eq!(array.len(), 0);
+/// let data = unsafe { core::slice::from_raw_parts(array.as_ptr(), array.capacity()) };
+/// assert_eq!(data, [0, 0, 0]);
+/// ```
+impl<Z: zeroize::Zeroize, const CAP: usize> zeroize::Zeroize for ArrayVec<Z, CAP> {
+ fn zeroize(&mut self) {
+ // Zeroize all the contained elements.
+ self.iter_mut().zeroize();
+ // Drop all the elements and set the length to 0.
+ self.clear();
+ // Zeroize the backing array.
+ self.xs.zeroize();
+ }
+}
+
/// By-value iterator for `ArrayVec`.
pub struct IntoIter<T, const CAP: usize> {
index: usize,
@@ -978,9 +1009,8 @@ impl<'a, T: 'a, const CAP: usize> Drop for Drain<'a, T, CAP> {
// memmove back untouched tail, update to new length
let start = source_vec.len();
let tail = self.tail_start;
- let src = source_vec.as_ptr().add(tail);
- let dst = source_vec.as_mut_ptr().add(start);
- ptr::copy(src, dst, self.tail_len);
+ let ptr = source_vec.as_mut_ptr();
+ ptr::copy(ptr.add(tail), ptr.add(start), self.tail_len);
source_vec.set_len(start + self.tail_len);
}
}
@@ -1012,6 +1042,7 @@ impl<T, const CAP: usize> Extend<T> for ArrayVec<T, CAP> {
/// Extend the `ArrayVec` with an iterator.
///
/// ***Panics*** if extending the vector exceeds its capacity.
+ #[track_caller]
fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) {
unsafe {
self.extend_from_iter::<_, true>(iter)
@@ -1021,6 +1052,7 @@ impl<T, const CAP: usize> Extend<T> for ArrayVec<T, CAP> {
#[inline(never)]
#[cold]
+#[track_caller]
fn extend_panic() {
panic!("ArrayVec: capacity exceeded in extend/from_iter");
}
@@ -1032,6 +1064,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
///
/// Unsafe because if CHECK is false, the length of the input is not checked.
/// The caller must ensure the length of the input fits in the capacity.
+ #[track_caller]
pub(crate) unsafe fn extend_from_iter<I, const CHECK: bool>(&mut self, iterable: I)
where I: IntoIterator<Item = T>
{
@@ -1082,7 +1115,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
unsafe fn raw_ptr_add<T>(ptr: *mut T, offset: usize) -> *mut T {
if mem::size_of::<T>() == 0 {
// Special case for ZST
- (ptr as usize).wrapping_add(offset) as _
+ ptr.cast::<u8>().wrapping_add(offset).cast()
} else {
ptr.add(offset)
}
diff --git a/vendor/arrayvec/src/arrayvec_impl.rs b/vendor/arrayvec/src/arrayvec_impl.rs
index 6c09834ad..c5ebe7b89 100644
--- a/vendor/arrayvec/src/arrayvec_impl.rs
+++ b/vendor/arrayvec/src/arrayvec_impl.rs
@@ -35,6 +35,7 @@ pub(crate) trait ArrayVecImpl {
/// Return a raw mutable pointer to the vector's buffer.
fn as_mut_ptr(&mut self) -> *mut Self::Item;
+ #[track_caller]
fn push(&mut self, element: Self::Item) {
self.try_push(element).unwrap()
}
diff --git a/vendor/arrayvec/src/lib.rs b/vendor/arrayvec/src/lib.rs
index 5dc0273a7..f9a2fe687 100644
--- a/vendor/arrayvec/src/lib.rs
+++ b/vendor/arrayvec/src/lib.rs
@@ -11,6 +11,10 @@
//! - Optional
//! - Enable serialization for ArrayVec and ArrayString using serde 1.x
//!
+//! - `zeroize`
+//! - Optional
+//! - Implement `Zeroize` for ArrayVec and ArrayString
+//!
//! ## Rust Version
//!
//! This version of arrayvec requires Rust 1.51 or later.