What changed, and why it matters
This is a routine maintenance update that upgrades the Rust compiler toolchain from an older version to Rust 1.90.0 for the BitBox02 hardware wallet firmware. It refreshes many third-party Rust libraries (vendored dependencies), adjusts build configuration files, and saves a small amount of firmware space. There is no direct evidence in the commit of a security vulnerability being fixed or introduced. The main security consideration is that compiler and library updates can change generated code behavior, so thorough testing is warranted, but nothing in the diff points to an active security issue.
Treat as a standard dependency/toolchain update. Verify that the firmware builds reproducibly, passes the existing test suite, and that binary size/behavior match expectations. Review release notes for Rust 1.90.0 and the updated vendored crates for any known security advisories, but no immediate security response is indicated by this commit.
Security signals we found
Routine toolchain and dependency update with no explicit security fix
Vendored crate refresh changes many checksums and Cargo.toml files
No project-level cryptographic or memory-safety code changes visible
No CVE or advisory references present in commit message or diff
Evidence from the diff
The commit bumps the Rust toolchain to 1.90.0, updates the container version, adjusts Dockerfile ENV syntax, and refreshes the vendored external/vendor crates. It also pins libc to 0.1.74 and cfg-if to 1.0.1 to deduplicate dependencies, disables the clippy::collapsible-if lint, and commits Cargo.toml.orig files because newer Cargo includes them in crate checksums. The actual project source files changed are minimal (rust-toolchain.toml, Cargo.lock, a few Rust source files for lint/compatibility fixes). The bulk of the diff is dependency metadata and vendored crate updates.
Changed components
Rust toolchain configuration (src/rust/rust-toolchain.toml)Docker build environment (Dockerfile, .containerversion, Makefile)Vendored Rust dependencies under external/vendor/src/rust/Cargo.locksrc/rust/bitbox-aes/src/lib.rssrc/rust/bitbox02-rust/src/bb02_async.rssrc/rust/bitbox02-rust/src/hww/api/bitcoin/policies.rsInspect captured patch +26870 / −97721
diff --git a/.containerversion b/.containerversion
index 95f9650f..e373ee69 100644
--- a/.containerversion
+++ b/.containerversion
@@ -1 +1 @@
-49
+50
diff --git a/.gitignore b/.gitignore
index c17fdbcf..9fd961d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,10 +22,3 @@ compile_flags.txt
bitbox02.egg-info
/py/bitbox02/build
/py/bitbox02/dist
-
-# Git backup files created on merge conflicts
-*_BACKUP_*
-*_BASE_*
-*_LOCAL_*
-*_REMOTE_*
-*.orig
diff --git a/Dockerfile b/Dockerfile
index d7e8ffe9..530b5657 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -19,7 +19,7 @@
# $ docker run --privileged --rm tonistiigi/binfmt --install arm64
FROM ubuntu:22.04
-ENV DEBIAN_FRONTEND noninteractive
+ENV DEBIAN_FRONTEND=noninteractive
# These are automatically provided by docker (no need for --build-arg)
ARG TARGETPLATFORM
@@ -117,7 +117,7 @@ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
curl -L0 ${PROTOC_URL} -o /tmp/protoc-21.2.zip && \
unzip /tmp/protoc-21.2.zip -d /opt/protoc && \
rm /tmp/protoc-21.2.zip
-ENV PATH /opt/protoc/bin:$PATH
+ENV PATH=/opt/protoc/bin:$PATH
# Make Python3 the default
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
@@ -129,18 +129,18 @@ RUN apt-get update && apt-get install -y \
RUN python3 -m pip install gcovr
# Install Go, used for the tools in tools/go and for test/gounittest
-ENV GOPATH /opt/go
-ENV GOROOT /opt/go_dist/go
-ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
+ENV GOPATH=/opt/go
+ENV GOROOT=/opt/go_dist/go
+ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
RUN mkdir -p /opt/go_dist && \
curl https://dl.google.com/go/go1.19.3.linux-${TARGETARCH}.tar.gz | tar -xz -C /opt/go_dist
# Install lcov from release (the one from the repos is too old).
RUN cd /opt && wget https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz && tar -xf lcov-1.14.tar.gz
-ENV PATH /opt/lcov-1.14/bin:$PATH
+ENV PATH=/opt/lcov-1.14/bin:$PATH
# Install rust compiler
-ENV PATH /opt/cargo/bin:$PATH
+ENV PATH=/opt/cargo/bin:$PATH
ENV RUSTUP_HOME=/opt/rustup
COPY src/rust/rust-toolchain.toml /tmp/rust-toolchain.toml
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | CARGO_HOME=/opt/cargo sh -s -- --default-toolchain $(grep -oP '(?<=channel = ")[^"]+' /tmp/rust-toolchain.toml) -y
diff --git a/Makefile b/Makefile
index 4e5dad74..0a5dd552 100644
--- a/Makefile
+++ b/Makefile
@@ -173,7 +173,7 @@ run-bootloader:
run-factory-setup-debug:
arm-none-eabi-gdb -x scripts/jlink.gdb build-debug/bin/factory-setup.elf
dockerinit:
- ./scripts/container.sh build --pull --force-rm --no-cache -t shiftcrypto/firmware_v2:$(shell cat .containerversion) .
+ ./scripts/container.sh build --pull -t shiftcrypto/firmware_v2:$(shell cat .containerversion) .
dockerpull:
./scripts/container.sh pull shiftcrypto/firmware_v2:$(shell cat .containerversion)
dockerdev:
diff --git a/external/vendor/addr2line/.cargo-checksum.json b/external/vendor/addr2line/.cargo-checksum.json
index d69be2c1..c40559cb 100644
--- a/external/vendor/addr2line/.cargo-checksum.json
+++ b/external/vendor/addr2line/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"0d04c7dddcffba3d83d4a05466c9b79cf13360c33f081fc9800596716bf954ce","Cargo.lock":"783a3adbf5047e30e0aa52f28dc6a0134534de715e5a36fd402c17e2eba43b1a","Cargo.toml":"940373297f67456852d5236a1eb7a3856bc672c69529cbbe6052ce5f85221170","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"e99d88d232bf57d70f0fb87f6b496d44b6653f99f8a63d250a54c61ea4bcde40","README.md":"c635ed91d7b0c87ff2f0f311cd1a31336d2cbc4d011965d3b58afaca073538d9","src/bin/addr2line.rs":"3da8c7657604578961f2bf89052b94e6c59c55abe27a2707913f98875d666124","src/frame.rs":"de3b23388c36a0874db5569d1f49ce6cc52ef2006b9ae9b9a3eba7654b201e2b","src/function.rs":"7fc741622c44c24fdf54c8a44cbdee058d49da33974bc86cd45b70c143071e68","src/lazy.rs":"ec230b69a0d194fe253227a41903231ca70a88f896af7a6f8a5a7d9ac63bf618","src/lib.rs":"8bf9fe3f3ced8ff84d60fdd456a8ff6e73170825cd696b0291b4644c01e620d2","src/line.rs":"049e9b1526ae3433a6001e8377245131e9cbd056d17e67a9b34898598a4f1c28","src/loader.rs":"9ad08da02599b9742a9821742fd84dbe0294838b6faa5f5753eacddc6101ffc1","src/lookup.rs":"0d28a2fd00f0696f8fb50cdc88cb7d55a910df8bf3052b7c74ae50a387346e67","src/unit.rs":"f4399c401759e14db5d596cfddfe2c8a0591a81c18d9adaedba7d243cc3bd192"},"package":"dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"}
\ No newline at end of file
+{"files":{".cargo_vcs_info.json":"61ea40c74a8ba6ecd523f8584b5e52454b0473bbb112e7cf4dce3d4d0f4f253a","CHANGELOG.md":"dc96b6ac3a534d948a55d17bf0144522e26cb6afaeafd79c3533b4988616ffea","Cargo.lock":"a5a5ca765a6f630c80e32310ffa92185a2805c7c364c07479bf2799524561807","Cargo.toml":"915a5053f0fe3a27a6e34a6f35e789ee09ac3bf3a7c4d07a62d68acd1d821104","Cargo.toml.orig":"fce3df826fb5d4229b290467e48252f8da5124213d5b8a5b1e7f0e953b01eef9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"e99d88d232bf57d70f0fb87f6b496d44b6653f99f8a63d250a54c61ea4bcde40","README.md":"c635ed91d7b0c87ff2f0f311cd1a31336d2cbc4d011965d3b58afaca073538d9","src/bin/addr2line.rs":"147c07d761c845c5faf3e1e3904c33374bc84bc79b2b95ae892b1def5ce6ced6","src/frame.rs":"de3b23388c36a0874db5569d1f49ce6cc52ef2006b9ae9b9a3eba7654b201e2b","src/function.rs":"6e0aceeb826db8fcec78376ee72b5dca098ae3e409e9defc5f1af9bfb2c7f173","src/lib.rs":"0baa05211611d9d79c3162a3e59f2cfe3334a71bece99bb337a7a2326a93093e","src/line.rs":"374afffcd11e38dc1b093d38b16b42d33c2a5fa9e7dbb759ecf15c1f6c58a7a0","src/loader.rs":"10ce28775d65bb32ed2995fae240b4f38499a80b56cdf17c079d166c9f1153f3","src/lookup.rs":"0d28a2fd00f0696f8fb50cdc88cb7d55a910df8bf3052b7c74ae50a387346e67","src/unit.rs":"5f2035954d86aa8dcb4d552ee8fb93c7f792d9fa2b6aeafa62f78b066363c8f5"},"package":"9acbfca36652500c911ddb767ed433e3ed99b032b5d935be73c6923662db1d43"}
\ No newline at end of file
diff --git a/external/vendor/addr2line/.cargo_vcs_info.json b/external/vendor/addr2line/.cargo_vcs_info.json
new file mode 100644
index 00000000..c261ad0e
--- /dev/null
+++ b/external/vendor/addr2line/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+ "git": {
+ "sha1": "2f260d1f4e36cc658fd2e1502bc0d65309cddb2c"
+ },
+ "path_in_vcs": ""
+}
\ No newline at end of file
diff --git a/external/vendor/addr2line/CHANGELOG.md b/external/vendor/addr2line/CHANGELOG.md
index 25a6d664..74deed56 100644
--- a/external/vendor/addr2line/CHANGELOG.md
+++ b/external/vendor/addr2line/CHANGELOG.md
@@ -2,6 +2,35 @@
--------------------------------------------------------------------------------
+## 0.25.0 (2025/06/11)
+
+### Breaking changes
+
+* Updated `gimli` dependency.
+
+### Added
+
+* Added `Loader::find_symbol`.
+ [#341](https://github.com/gimli-rs/addr2line/pull/341)
+ [#349](https://github.com/gimli-rs/addr2line/pull/349)
+
+* Added `Loader::get_section_range`.
+ Added `--section` option to `addr2line` binary.
+ [#343](https://github.com/gimli-rs/addr2line/pull/343)
+
+* Added `wasm` feature.
+ [#348](https://github.com/gimli-rs/addr2line/pull/348)
+
+### Changed
+
+* Fixed handling of Windows paths that use forward slashes.
+ [#342](https://github.com/gimli-rs/addr2line/pull/342)
+
+* Removed `compiler-builtins` from `rustc-dep-of-std` dependencies.
+ [#345](https://github.com/gimli-rs/addr2line/pull/345)
+
+--------------------------------------------------------------------------------
+
## 0.24.2 (2024/10/04)
### Changed
diff --git a/external/vendor/addr2line/Cargo.lock b/external/vendor/addr2line/Cargo.lock
index 2b4b65f8..76c8d44f 100644
--- a/external/vendor/addr2line/Cargo.lock
+++ b/external/vendor/addr2line/Cargo.lock
@@ -4,27 +4,27 @@ version = 3
[[package]]
name = "addr2line"
-version = "0.24.1"
+version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375"
+checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
dependencies = [
- "gimli",
+ "gimli 0.31.1",
]
[[package]]
name = "addr2line"
-version = "0.24.2"
+version = "0.25.0"
dependencies = [
"backtrace",
"clap",
- "compiler_builtins",
"cpp_demangle",
+ "criterion",
"fallible-iterator",
"findshlibs",
- "gimli",
+ "gimli 0.32.0",
"libtest-mimic",
"memmap2",
- "object",
+ "object 0.37.1",
"rustc-demangle",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
@@ -34,15 +34,30 @@ dependencies = [
[[package]]
name = "adler2"
-version = "2.0.0"
+version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
+checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anes"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstream"
-version = "0.6.15"
+version = "0.6.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
+checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
dependencies = [
"anstyle",
"anstyle-parse",
@@ -55,79 +70,125 @@ dependencies = [
[[package]]
name = "anstyle"
-version = "1.0.8"
+version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
+checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
[[package]]
name = "anstyle-parse"
-version = "0.2.5"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
+checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
-version = "1.1.1"
+version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
+checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
dependencies = [
- "windows-sys 0.52.0",
+ "windows-sys",
]
[[package]]
name = "anstyle-wincon"
-version = "3.0.4"
+version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
+checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
dependencies = [
"anstyle",
- "windows-sys 0.52.0",
+ "once_cell_polyfill",
+ "windows-sys",
]
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
[[package]]
name = "backtrace"
-version = "0.3.74"
+version = "0.3.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
+checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
dependencies = [
- "addr2line 0.24.1",
+ "addr2line 0.24.2",
"cfg-if",
"libc",
"miniz_oxide",
- "object",
+ "object 0.36.7",
"rustc-demangle",
"windows-targets",
]
[[package]]
name = "bitflags"
-version = "2.6.0"
+version = "2.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
+
+[[package]]
+name = "bumpalo"
+version = "3.18.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "793db76d6187cd04dff33004d8e6c9cc4e05cd330500379d2394209271b4aeee"
+
+[[package]]
+name = "cast"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
+checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
-version = "1.1.24"
+version = "1.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
+checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
-version = "1.0.0"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
+
+[[package]]
+name = "ciborium"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
+dependencies = [
+ "ciborium-io",
+ "ciborium-ll",
+ "serde",
+]
+
+[[package]]
+name = "ciborium-io"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
+
+[[package]]
+name = "ciborium-ll"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
+dependencies = [
+ "ciborium-io",
+ "half",
+]
[[package]]
name = "clap"
-version = "4.5.19"
+version = "4.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615"
+checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f"
dependencies = [
"clap_builder",
"clap_derive",
@@ -135,9 +196,9 @@ dependencies = [
[[package]]
name = "clap_builder"
-version = "4.5.19"
+version = "4.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b"
+checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e"
dependencies = [
"anstream",
"anstyle",
@@ -148,9 +209,9 @@ dependencies = [
[[package]]
name = "clap_derive"
-version = "4.5.18"
+version = "4.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
+checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce"
dependencies = [
"heck",
"proc-macro2",
@@ -160,21 +221,15 @@ dependencies = [
[[package]]
name = "clap_lex"
-version = "0.7.2"
+version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
+checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
[[package]]
name = "colorchoice"
-version = "1.0.2"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
-
-[[package]]
-name = "compiler_builtins"
-version = "0.1.131"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d18d2ba094b78965890b2912f45dc8cb6bb3aff315ef54755ec33223b6454502"
+checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "cpp_demangle"
@@ -194,14 +249,84 @@ dependencies = [
"cfg-if",
]
+[[package]]
+name = "criterion"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bf7af66b0989381bd0be551bd7cc91912a655a58c6918420c9527b1fd8b4679"
+dependencies = [
+ "anes",
+ "cast",
+ "ciborium",
+ "clap",
+ "criterion-plot",
+ "itertools 0.13.0",
+ "num-traits",
+ "oorandom",
+ "plotters",
+ "rayon",
+ "regex",
+ "serde",
+ "serde_json",
+ "tinytemplate",
+ "walkdir",
+]
+
+[[package]]
+name = "criterion-plot"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
+dependencies = [
+ "cast",
+ "itertools 0.10.5",
+]
+
+[[package]]
+name = "crossbeam-deque"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
+dependencies = [
+ "crossbeam-epoch",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-epoch"
+version = "0.9.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
+
+[[package]]
+name = "crunchy"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
+
+[[package]]
+name = "either"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
+
[[package]]
name = "errno"
-version = "0.3.9"
+version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
+checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18"
dependencies = [
"libc",
- "windows-sys 0.52.0",
+ "windows-sys",
]
[[package]]
@@ -230,9 +355,9 @@ dependencies = [
[[package]]
name = "flate2"
-version = "1.0.34"
+version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
+checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d"
dependencies = [
"crc32fast",
"miniz_oxide",
@@ -243,8 +368,13 @@ name = "gimli"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
+
+[[package]]
+name = "gimli"
+version = "0.32.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93563d740bc9ef04104f9ed6f86f1e3275c2cdafb95664e26584b9ca807a8ffe"
dependencies = [
- "compiler_builtins",
"fallible-iterator",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
@@ -252,16 +382,20 @@ dependencies = [
]
[[package]]
-name = "heck"
-version = "0.5.0"
+name = "half"
+version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+]
[[package]]
-name = "hermit-abi"
-version = "0.3.9"
+name = "heck"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
@@ -269,6 +403,40 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+[[package]]
+name = "itertools"
+version = "0.10.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itertools"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
+
+[[package]]
+name = "js-sys"
+version = "0.3.77"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
+dependencies = [
+ "once_cell",
+ "wasm-bindgen",
+]
+
[[package]]
name = "lazy_static"
version = "1.5.0"
@@ -277,27 +445,33 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
-version = "0.2.159"
+version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
+checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
[[package]]
name = "libtest-mimic"
-version = "0.7.3"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc0bda45ed5b3a2904262c1bb91e526127aa70e7ef3758aba2ef93cf896b9b58"
+checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33"
dependencies = [
+ "anstream",
+ "anstyle",
"clap",
"escape8259",
- "termcolor",
- "threadpool",
]
[[package]]
name = "linux-raw-sys"
-version = "0.4.14"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
+
+[[package]]
+name = "log"
+version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "memchr"
@@ -316,92 +490,249 @@ dependencies = [
[[package]]
name = "miniz_oxide"
-version = "0.8.0"
+version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
+checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
]
[[package]]
-name = "num_cpus"
-version = "1.16.0"
+name = "num-traits"
+version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
- "hermit-abi",
- "libc",
+ "autocfg",
+]
+
+[[package]]
+name = "object"
+version = "0.36.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
+dependencies = [
+ "memchr",
]
[[package]]
name = "object"
-version = "0.36.5"
+version = "0.37.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
+checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a"
dependencies = [
"flate2",
"memchr",
"ruzstd",
+ "wasmparser",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
+
+[[package]]
+name = "oorandom"
+version = "11.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
+
+[[package]]
+name = "plotters"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
+dependencies = [
+ "num-traits",
+ "plotters-backend",
+ "plotters-svg",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
+name = "plotters-backend"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a"
+
+[[package]]
+name = "plotters-svg"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670"
+dependencies = [
+ "plotters-backend",
]
[[package]]
name = "proc-macro2"
-version = "1.0.86"
+version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
+checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.37"
+version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
+checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
+[[package]]
+name = "rayon"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
+dependencies = [
+ "either",
+ "rayon-core",
+]
+
+[[package]]
+name = "rayon-core"
+version = "1.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
+dependencies = [
+ "crossbeam-deque",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "regex"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+
[[package]]
name = "rustc-demangle"
-version = "0.1.24"
+version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
+checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
[[package]]
name = "rustc-std-workspace-alloc"
-version = "1.0.0"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff66d57013a5686e1917ed6a025d54dd591fcda71a41fe07edf4d16726aefa86"
+checksum = "f9d441c3b2ebf55cebf796bfdc265d67fa09db17b7bb6bd4be75c509e1e8fec3"
[[package]]
name = "rustc-std-workspace-core"
-version = "1.0.0"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c"
+checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955"
[[package]]
name = "rustix"
-version = "0.38.37"
+version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
+checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
- "windows-sys 0.52.0",
+ "windows-sys",
]
+[[package]]
+name = "rustversion"
+version = "1.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
+
[[package]]
name = "ruzstd"
-version = "0.7.2"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99c3938e133aac070997ddc684d4b393777d293ba170f2988c8fd5ea2ad4ce21"
+checksum = "3640bec8aad418d7d03c72ea2de10d5c646a598f9883c7babc160d91e3c1b26c"
dependencies = [
"twox-hash",
]
+[[package]]
+name = "ryu"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.219"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.140"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
+dependencies = [
+ "itoa",
+ "memchr",
+ "ryu",
+ "serde",
+]
+
[[package]]
name = "shlex"
version = "1.3.0"
@@ -410,9 +741,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "smallvec"
-version = "1.13.2"
+version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "stable_deref_trait"
@@ -420,12 +751,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
-[[package]]
-name = "static_assertions"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
-
[[package]]
name = "strsim"
version = "0.11.1"
@@ -434,52 +759,40 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
-version = "2.0.79"
+version = "2.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
+checksum = "f6397daf94fa90f058bd0fd88429dd9e5738999cca8d701813c80723add80462"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
-[[package]]
-name = "termcolor"
-version = "1.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
-dependencies = [
- "winapi-util",
-]
-
[[package]]
name = "terminal_size"
-version = "0.4.0"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef"
+checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed"
dependencies = [
"rustix",
- "windows-sys 0.59.0",
+ "windows-sys",
]
[[package]]
-name = "threadpool"
-version = "1.8.1"
+name = "tinytemplate"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
+checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
dependencies = [
- "num_cpus",
+ "serde",
+ "serde_json",
]
[[package]]
name = "twox-hash"
-version = "1.6.3"
+version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
-dependencies = [
- "cfg-if",
- "static_assertions",
-]
+checksum = "8b907da542cbced5261bd3256de1b3a1bf340a3d37f93425a07362a1d687de56"
[[package]]
name = "typed-arena"
@@ -489,9 +802,9 @@ checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "unicode-ident"
-version = "1.0.13"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
+checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "utf8parse"
@@ -499,6 +812,93 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+[[package]]
+name = "walkdir"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
+dependencies = [
+ "bumpalo",
+ "log",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "wasmparser"
+version = "0.234.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be22e5a8f600afce671dd53c8d2dd26b4b7aa810fd18ae27dfc49737f3e02fc5"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "web-sys"
+version = "0.3.77"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
[[package]]
name = "winapi"
version = "0.3.9"
@@ -521,7 +921,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys",
]
[[package]]
@@ -530,15 +930,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-[[package]]
-name = "windows-sys"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
-dependencies = [
- "windows-targets",
-]
-
[[package]]
name = "windows-sys"
version = "0.59.0"
diff --git a/external/vendor/addr2line/Cargo.toml b/external/vendor/addr2line/Cargo.toml
index c94e8b26..1c9c70bb 100644
--- a/external/vendor/addr2line/Cargo.toml
+++ b/external/vendor/addr2line/Cargo.toml
@@ -11,9 +11,9 @@
[package]
edition = "2018"
-rust-version = "1.65"
+rust-version = "1.81"
name = "addr2line"
-version = "0.24.2"
+version = "0.25.0"
build = false
include = [
"/CHANGELOG.md",
@@ -24,6 +24,7 @@ include = [
"/README.md",
"/src",
]
+autolib = false
autobins = false
autoexamples = false
autotests = false
@@ -42,12 +43,40 @@ categories = ["development-tools::debugging"]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/gimli-rs/addr2line"
-[profile.bench]
-codegen-units = 1
-debug = 2
-
-[profile.release]
-debug = 2
+[features]
+all = [
+ "bin",
+ "wasm",
+]
+bin = [
+ "loader",
+ "rustc-demangle",
+ "cpp_demangle",
+ "fallible-iterator",
+ "smallvec",
+ "dep:clap",
+]
+cargo-all = []
+default = [
+ "rustc-demangle",
+ "cpp_demangle",
+ "loader",
+ "fallible-iterator",
+ "smallvec",
+]
+loader = [
+ "std",
+ "dep:object",
+ "dep:memmap2",
+ "dep:typed-arena",
+]
+rustc-dep-of-std = [
+ "core",
+ "alloc",
+ "gimli/rustc-dep-of-std",
+]
+std = ["gimli/std"]
+wasm = ["object/wasm"]
[lib]
name = "addr2line"
@@ -68,10 +97,6 @@ version = "4.3.21"
features = ["wrap_help"]
optional = true
-[dependencies.compiler_builtins]
-version = "0.1.2"
-optional = true
-
[dependencies.core]
version = "1.0.0"
optional = true
@@ -89,7 +114,7 @@ optional = true
default-features = false
[dependencies.gimli]
-version = "0.31.1"
+version = "0.32.0"
features = ["read"]
default-features = false
@@ -98,7 +123,7 @@ version = "0.9.4"
optional = true
[dependencies.object]
-version = "0.36.0"
+version = "0.37.0"
features = [
"read",
"compression",
@@ -122,40 +147,18 @@ optional = true
[dev-dependencies.backtrace]
version = "0.3.13"
+[dev-dependencies.criterion]
+version = "0.6.0"
+
[dev-dependencies.findshlibs]
version = "0.10"
[dev-dependencies.libtest-mimic]
-version = "0.7.2"
+version = "0.8.1"
-[features]
-all = ["bin"]
-bin = [
- "loader",
- "rustc-demangle",
- "cpp_demangle",
- "fallible-iterator",
- "smallvec",
- "dep:clap",
-]
-cargo-all = []
-default = [
- "rustc-demangle",
- "cpp_demangle",
- "loader",
- "fallible-iterator",
- "smallvec",
-]
-loader = [
- "std",
- "dep:object",
- "dep:memmap2",
- "dep:typed-arena",
-]
-rustc-dep-of-std = [
- "core",
- "alloc",
- "compiler_builtins",
- "gimli/rustc-dep-of-std",
-]
-std = ["gimli/std"]
+[profile.bench]
+codegen-units = 1
+debug = 2
+
+[profile.release]
+debug = 2
diff --git a/external/vendor/addr2line/Cargo.toml.orig b/external/vendor/addr2line/Cargo.toml.orig
new file mode 100644
index 00000000..58039350
--- /dev/null
+++ b/external/vendor/addr2line/Cargo.toml.orig
@@ -0,0 +1,92 @@
+[package]
+name = "addr2line"
+version = "0.25.0"
+description = "A cross-platform symbolication library written in Rust, using `gimli`"
+documentation = "https://docs.rs/addr2line"
+keywords = ["DWARF", "debug", "elf", "symbolicate", "atos"]
+categories = ["development-tools::debugging"]
+license = "Apache-2.0 OR MIT"
+readme = "./README.md"
+repository = "https://github.com/gimli-rs/addr2line"
+edition = "2018"
+rust-version = "1.81"
+include = [
+ "/CHANGELOG.md",
+ "/Cargo.lock",
+ "/Cargo.toml",
+ "/LICENSE-APACHE",
+ "/LICENSE-MIT",
+ "/README.md",
+ "/src",
+]
+
+[dependencies]
+gimli = { version = "0.32.0", default-features = false, features = ["read"] }
+fallible-iterator = { version = "0.3.0", default-features = false, optional = true }
+smallvec = { version = "1", default-features = false, optional = true }
+rustc-demangle = { version = "0.1", optional = true }
+cpp_demangle = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
+
+# loader dependencies
+object = { version = "0.37.0", default-features = false, features = ["read", "compression"], optional = true }
+memmap2 = { version = "0.9.4", optional = true }
+typed-arena = { version = "2", optional = true }
+
+# bin dependencies
+clap = { version = "4.3.21", features = ["wrap_help"], optional = true }
+
+# Internal feature, only used when building as part of libstd, not part of the
+# stable interface of this crate.
+core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
+alloc = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-alloc' }
+
+[dev-dependencies]
+backtrace = "0.3.13"
+criterion = "0.6.0"
+findshlibs = "0.10"
+libtest-mimic = "0.8.1"
+auxiliary = { path = "tests/auxiliary" }
+
+[profile.release]
+debug = true
+
+[profile.bench]
+debug = true
+codegen-units = 1
+
+[features]
+default = ["rustc-demangle", "cpp_demangle", "loader", "fallible-iterator", "smallvec"]
+std = ["gimli/std"]
+wasm = ["object/wasm"]
+loader = ["std", "dep:object", "dep:memmap2", "dep:typed-arena"]
+bin = ["loader", "rustc-demangle", "cpp_demangle", "fallible-iterator", "smallvec", "dep:clap"]
+all = ["bin", "wasm"]
+
+# Use of --all-features is not supported.
+# This is a dummy feature to detect when --all-features is used.
+cargo-all = []
+
+# Internal feature, only used when building as part of libstd, not part of the
+# stable interface of this crate.
+rustc-dep-of-std = ['core', 'alloc', 'gimli/rustc-dep-of-std']
+
+[[test]]
+name = "testinput"
+harness = false
+required-features = ["bin"]
+
+[[test]]
+name = "correctness"
+required-features = ["loader", "fallible-iterator"]
+
+[[test]]
+name = "parse"
+required-features = ["loader"]
+
+[[bin]]
+name = "addr2line"
+required-features = ["bin"]
+
+[[bench]]
+name = "bench"
+harness = false
diff --git a/external/vendor/addr2line/src/bin/addr2line.rs b/external/vendor/addr2line/src/bin/addr2line.rs
index da630ff9..150ee9ab 100644
--- a/external/vendor/addr2line/src/bin/addr2line.rs
+++ b/external/vendor/addr2line/src/bin/addr2line.rs
@@ -96,6 +96,7 @@ struct Options<'a> {
llvm: bool,
exe: &'a PathBuf,
sup: Option<&'a PathBuf>,
+ section: Option<&'a String>,
}
fn main() {
@@ -118,6 +119,13 @@ fn main() {
.value_name("filename")
.value_parser(clap::value_parser!(PathBuf))
.help("Path to supplementary object file."),
+ Arg::new("section")
+ .short('j')
+ .long("section")
+ .value_name("name")
+ .help(
+ "Read offsets relative to the specified section instead of absolute addresses.",
+ ),
Arg::new("all")
.long("all")
.action(ArgAction::SetTrue)
@@ -176,10 +184,16 @@ fn main() {
llvm: matches.get_flag("llvm"),
exe: matches.get_one::<PathBuf>("exe").unwrap(),
sup: matches.get_one::<PathBuf>("sup"),
+ section: matches.get_one::<String>("section"),
};
let ctx = Loader::new_with_sup(opts.exe, opts.sup).unwrap();
+ let section_range = opts.section.map(|section_name| {
+ ctx.get_section_range(section_name.as_bytes())
+ .unwrap_or_else(|| panic!("cannot find section {}", section_name))
+ });
+
let stdin = std::io::stdin();
let addrs = if matches.get_flag("all") {
Addrs::All {
@@ -208,6 +222,20 @@ fn main() {
}
}
+ // If --section is given, add the section address to probe.
+ let probe = probe.and_then(|probe| {
+ if let Some(section_range) = section_range {
+ if probe < (section_range.end - section_range.begin) {
+ Some(probe + section_range.begin)
+ } else {
+ // If addr >= section size, treat it as if no line number information was found.
+ None
+ }
+ } else {
+ Some(probe)
+ }
+ });
+
if opts.do_functions || opts.do_inlines {
let mut printed_anything = false;
if let Some(probe) = probe {
diff --git a/external/vendor/addr2line/src/function.rs b/external/vendor/addr2line/src/function.rs
index cddd628a..e84c80f1 100644
--- a/external/vendor/addr2line/src/function.rs
+++ b/external/vendor/addr2line/src/function.rs
@@ -2,9 +2,8 @@ use alloc::boxed::Box;
use alloc::vec::Vec;
use core::cmp::Ordering;
-use crate::lazy::LazyResult;
use crate::maybe_small;
-use crate::{Context, DebugFile, Error, RangeAttributes};
+use crate::{Context, DebugFile, Error, LazyResult, RangeAttributes};
pub(crate) struct LazyFunctions<R: gimli::Reader>(LazyResult<Functions<R>>);
@@ -15,7 +14,7 @@ impl<R: gimli::Reader> LazyFunctions<R> {
pub(crate) fn borrow(&self, unit: gimli::UnitRef<R>) -> Result<&Functions<R>, Error> {
self.0
- .borrow_with(|| Functions::parse(unit))
+ .get_or_init(|| Functions::parse(unit))
.as_ref()
.map_err(Error::clone)
}
@@ -59,7 +58,7 @@ impl<R: gimli::Reader> LazyFunction<R> {
ctx: &Context<R>,
) -> Result<&Function<R>, Error> {
self.lazy
- .borrow_with(|| Function::parse(self.dw_die_offset, file, unit, ctx))
+ .get_or_init(|| Function::parse(self.dw_die_offset, file, unit, ctx))
.as_ref()
.map_err(Error::clone)
}
diff --git a/external/vendor/addr2line/src/lazy.rs b/external/vendor/addr2line/src/lazy.rs
deleted file mode 100644
index 4460b8ae..00000000
--- a/external/vendor/addr2line/src/lazy.rs
+++ /dev/null
@@ -1,34 +0,0 @@
-use core::cell::UnsafeCell;
-
-pub(crate) type LazyResult<T> = LazyCell<Result<T, crate::Error>>;
-
-pub(crate) struct LazyCell<T> {
- contents: UnsafeCell<Option<T>>,
-}
-
-impl<T> LazyCell<T> {
- pub(crate) fn new() -> LazyCell<T> {
- LazyCell {
- contents: UnsafeCell::new(None),
- }
- }
-
- pub(crate) fn borrow(&self) -> Option<&T> {
- unsafe { &*self.contents.get() }.as_ref()
- }
-
- pub(crate) fn borrow_with(&self, closure: impl FnOnce() -> T) -> &T {
- // First check if we're already initialized...
- let ptr = self.contents.get();
- if let Some(val) = unsafe { &*ptr } {
- return val;
- }
- // Note that while we're executing `closure` our `borrow_with` may
- // be called recursively. This means we need to check again after
- // the closure has executed. For that we use the `get_or_insert`
- // method which will only perform mutation if we aren't already
- // `Some`.
- let val = closure();
- unsafe { (*ptr).get_or_insert(val) }
- }
-}
diff --git a/external/vendor/addr2line/src/lib.rs b/external/vendor/addr2line/src/lib.rs
index e12d8efa..5e67e72d 100644
--- a/external/vendor/addr2line/src/lib.rs
+++ b/external/vendor/addr2line/src/lib.rs
@@ -42,6 +42,7 @@ pub extern crate fallible_iterator;
pub extern crate gimli;
use alloc::sync::Arc;
+use core::cell::OnceCell;
use core::ops::ControlFlow;
use crate::function::{Function, Functions, InlinedFunction, LazyFunctions};
@@ -64,13 +65,12 @@ mod frame;
pub use frame::{demangle, demangle_auto, Frame, FrameIter, FunctionName, Location};
mod function;
-mod lazy;
mod line;
#[cfg(feature = "loader")]
mod loader;
#[cfg(feature = "loader")]
-pub use loader::{Loader, LoaderReader};
+pub use loader::{Loader, LoaderReader, Symbol};
mod lookup;
pub use lookup::{LookupContinuation, LookupResult, SplitDwarfLoad};
@@ -79,6 +79,7 @@ mod unit;
pub use unit::LocationRangeIter;
type Error = gimli::Error;
+type LazyResult<T> = OnceCell<Result<T, Error>>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum DebugFile {
@@ -122,6 +123,8 @@ impl<R: gimli::Reader> Context<R> {
debug_info,
debug_line,
debug_line_str,
+ debug_macinfo: default_section.clone().into(),
+ debug_macro: default_section.clone().into(),
debug_str,
debug_str_offsets,
debug_types: default_section.clone().into(),
diff --git a/external/vendor/addr2line/src/line.rs b/external/vendor/addr2line/src/line.rs
index 39d31a8c..4b1c95dc 100644
--- a/external/vendor/addr2line/src/line.rs
+++ b/external/vendor/addr2line/src/line.rs
@@ -5,8 +5,7 @@ use core::cmp::Ordering;
use core::mem;
use core::num::NonZeroU64;
-use crate::lazy::LazyResult;
-use crate::{Error, Location};
+use crate::{Error, LazyResult, Location};
pub(crate) struct LazyLines(LazyResult<Lines>);
@@ -21,7 +20,7 @@ impl LazyLines {
ilnp: &gimli::IncompleteLineProgram<R, R::Offset>,
) -> Result<&Lines, Error> {
self.0
- .borrow_with(|| Lines::parse(dw_unit, ilnp.clone()))
+ .get_or_init(|| Lines::parse(dw_unit, ilnp.clone()))
.as_ref()
.map_err(Error::clone)
}
@@ -287,10 +286,10 @@ fn render_file<R: gimli::Reader>(
}
fn path_push(path: &mut String, p: &str) {
- if has_unix_root(p) || has_windows_root(p) {
+ if has_forward_slash_root(p) || has_backward_slash_root(p) {
*path = p.to_string();
} else {
- let dir_separator = if has_windows_root(path.as_str()) {
+ let dir_separator = if has_backward_slash_root(path.as_str()) {
'\\'
} else {
'/'
@@ -304,11 +303,11 @@ fn path_push(path: &mut String, p: &str) {
}
/// Check if the path in the given string has a unix style root
-fn has_unix_root(p: &str) -> bool {
- p.starts_with('/')
+fn has_forward_slash_root(p: &str) -> bool {
+ p.starts_with('/') || p.get(1..3) == Some(":/")
}
/// Check if the path in the given string has a windows style root
-fn has_windows_root(p: &str) -> bool {
+fn has_backward_slash_root(p: &str) -> bool {
p.starts_with('\\') || p.get(1..3) == Some(":\\")
}
diff --git a/external/vendor/addr2line/src/loader.rs b/external/vendor/addr2line/src/loader.rs
index edf90e6c..e0265b18 100644
--- a/external/vendor/addr2line/src/loader.rs
+++ b/external/vendor/addr2line/src/loader.rs
@@ -2,6 +2,7 @@ use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::sync::Arc;
use alloc::vec::Vec;
+use core::cell::OnceCell;
use std::ffi::OsStr;
use std::fs::File;
use std::path::{Path, PathBuf};
@@ -10,7 +11,6 @@ use memmap2::Mmap;
use object::{Object, ObjectMapFile, ObjectSection, SymbolMap, SymbolMapName};
use typed_arena::Arena;
-use crate::lazy::LazyCell;
use crate::{
Context, FrameIter, Location, LocationRangeIter, LookupContinuation, LookupResult,
SplitDwarfLoad,
@@ -126,20 +126,32 @@ impl Loader {
}
/// Find the symbol table entry corresponding to the given virtual memory address.
+ /// Return the symbol name.
pub fn find_symbol(&self, probe: u64) -> Option<&str> {
- self.borrow_internal(|i, _data, _mmap| i.find_symbol(probe))
+ self.find_symbol_info(probe).map(|symbol| symbol.name)
+ }
+
+ /// Find the symbol table entry corresponding to the given virtual memory address.
+ pub fn find_symbol_info(&self, probe: u64) -> Option<Symbol> {
+ self.borrow_internal(|i, _data, _mmap| i.find_symbol_info(probe))
+ }
+
+ /// Get the address of a section
+ pub fn get_section_range(&self, section_name: &[u8]) -> Option<gimli::Range> {
+ self.borrow_internal(|i, _data, _mmap| i.get_section_range(section_name))
}
}
struct LoaderInternal<'a> {
ctx: Context<LoaderReader<'a>>,
+ object: object::File<'a>,
relative_address_base: u64,
symbols: SymbolMap<SymbolMapName<'a>>,
dwarf_package: Option<gimli::DwarfPackage<LoaderReader<'a>>>,
// Map from address to Mach-O object file path.
object_map: object::ObjectMap<'a>,
// A context for each Mach-O object file.
- objects: Vec<LazyCell<Option<ObjectContext<'a>>>>,
+ objects: Vec<OnceCell<Option<ObjectContext<'a>>>>,
}
impl<'a> LoaderInternal<'a> {
@@ -151,13 +163,13 @@ impl<'a> LoaderInternal<'a> {
) -> Result<Self> {
let file = File::open(path)?;
let map = arena_mmap.alloc(unsafe { Mmap::map(&file)? });
- let mut object = object::File::parse(&**map)?;
+ let object = object::File::parse(&**map)?;
let relative_address_base = object.relative_address_base();
let symbols = object.symbol_map();
let object_map = object.object_map();
let mut objects = Vec::new();
- objects.resize_with(object_map.objects().len(), LazyCell::new);
+ objects.resize_with(object_map.objects().len(), OnceCell::new);
// Load supplementary object file.
// TODO: use debuglink and debugaltlink
@@ -171,7 +183,7 @@ impl<'a> LoaderInternal<'a> {
};
// Load Mach-O dSYM file, ignoring errors.
- if let Some(map) = (|| {
+ let dsym = if let Some(map) = (|| {
let uuid = object.mach_uuid().ok()??;
path.parent()?.read_dir().ok()?.find_map(|candidate| {
let candidate = candidate.ok()?;
@@ -195,17 +207,21 @@ impl<'a> LoaderInternal<'a> {
})
})() {
let map = arena_mmap.alloc(map);
- object = object::File::parse(&**map)?;
- }
+ Some(object::File::parse(&**map)?)
+ } else {
+ None
+ };
+ let dwarf_object = dsym.as_ref().unwrap_or(&object);
// Load the DWARF sections.
- let endian = if object.is_little_endian() {
+ let endian = if dwarf_object.is_little_endian() {
gimli::RunTimeEndian::Little
} else {
gimli::RunTimeEndian::Big
};
- let mut dwarf =
- gimli::Dwarf::load(|id| load_section(Some(id.name()), &object, endian, arena_data))?;
+ let mut dwarf = gimli::Dwarf::load(|id| {
+ load_section(Some(id.name()), dwarf_object, endian, arena_data)
+ })?;
if let Some(sup_object) = &sup_object {
dwarf.load_sup(|id| load_section(Some(id.name()), sup_object, endian, arena_data))?;
}
@@ -244,6 +260,7 @@ impl<'a> LoaderInternal<'a> {
Ok(LoaderInternal {
ctx,
+ object,
relative_address_base,
symbols,
dwarf_package,
@@ -270,15 +287,28 @@ impl<'a> LoaderInternal<'a> {
) -> Option<(&Context<LoaderReader<'a>>, u64)> {
let symbol = self.object_map.get(probe)?;
let object_context = self.objects[symbol.object_index()]
- .borrow_with(|| {
+ .get_or_init(|| {
ObjectContext::new(symbol.object(&self.object_map), arena_data, arena_mmap)
})
.as_ref()?;
object_context.ctx(symbol.name(), probe - symbol.address())
}
- fn find_symbol(&self, probe: u64) -> Option<&str> {
- self.symbols.get(probe).map(|x| x.name())
+ fn find_symbol_info(&self, probe: u64) -> Option<Symbol> {
+ self.symbols.get(probe).map(|x| Symbol {
+ name: x.name(),
+ address: x.address(),
+ })
+ }
+
+ fn get_section_range(&self, section_name: &[u8]) -> Option<gimli::Range> {
+ self.object
+ .section_by_name_bytes(section_name)
+ .map(|section| {
+ let begin = section.address();
+ let end = begin + section.size();
+ gimli::Range { begin, end }
+ })
}
fn find_location(
@@ -449,3 +479,21 @@ fn convert_path(bytes: &[u8]) -> Result<PathBuf> {
let s = std::str::from_utf8(bytes)?;
Ok(PathBuf::from(s))
}
+
+/// Information from a symbol table entry.
+pub struct Symbol<'a> {
+ name: &'a str,
+ address: u64,
+}
+
+impl<'a> Symbol<'a> {
+ /// Get the symbol name.
+ pub fn name(&self) -> &'a str {
+ self.name
+ }
+
+ /// Get the symbol address.
+ pub fn address(&self) -> u64 {
+ self.address
+ }
+}
diff --git a/external/vendor/addr2line/src/unit.rs b/external/vendor/addr2line/src/unit.rs
index cb2985e9..946d2488 100644
--- a/external/vendor/addr2line/src/unit.rs
+++ b/external/vendor/addr2line/src/unit.rs
@@ -3,9 +3,8 @@ use alloc::sync::Arc;
use alloc::vec::Vec;
use core::cmp;
-use crate::lazy::LazyResult;
use crate::{
- Context, DebugFile, Error, Function, Functions, LazyFunctions, LazyLines,
+ Context, DebugFile, Error, Function, Functions, LazyFunctions, LazyLines, LazyResult,
LineLocationRangeIter, Lines, Location, LookupContinuation, LookupResult, RangeAttributes,
SimpleLookup, SplitDwarfLoad,
};
@@ -52,13 +51,13 @@ impl<R: gimli::Reader> ResUnit<R> {
};
let complete = |dwo| SimpleLookup::new_complete(map_dwo(dwo));
- if let Some(dwo) = self.dwo.borrow() {
+ if let Some(dwo) = self.dwo.get() {
return complete(dwo);
}
let dwo_id = match self.dw_unit.dwo_id {
None => {
- return complete(self.dwo.borrow_with(|| Ok(None)));
+ return complete(self.dwo.get_or_init(|| Ok(None)));
}
Some(dwo_id) => dwo_id,
};
@@ -76,7 +75,7 @@ impl<R: gimli::Reader> ResUnit<R> {
let path = match dwo_name {
Ok(v) => v,
Err(e) => {
- return complete(self.dwo.borrow_with(|| Err(e)));
+ return complete(self.dwo.get_or_init(|| Err(e)));
}
};
@@ -106,7 +105,7 @@ impl<R: gimli::Reader> ResUnit<R> {
path,
parent: ctx.sections.clone(),
},
- move |dwo_dwarf| map_dwo(self.dwo.borrow_with(|| process_dwo(dwo_dwarf))),
+ move |dwo_dwarf| map_dwo(self.dwo.get_or_init(|| process_dwo(dwo_dwarf))),
)
}
diff --git a/external/vendor/adler2/.cargo-checksum.json b/external/vendor/adler2/.cargo-checksum.json
index 14e102f6..7020e9d9 100644
--- a/external/vendor/adler2/.cargo-checksum.json
+++ b/external/vendor/adler2/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"52435caf085b428cdb6171a34f4980f52aaaf541a3dced226c92eb82f69a48a7","Cargo.toml":"56b9cca6450964cbe772b6519bc048c2f56cc80e9261de1126d789c5e1951136","LICENSE-0BSD":"861399f8c21c042b110517e76dc6b63a2b334276c8cf17412fc3c8908ca8dc17","LICENSE-APACHE":"8ada45cd9f843acf64e4722ae262c622a2b3b3007c7310ef36ac1061a30f6adb","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"cd955d5d6a49161e6f7a04df4a5963581b66ed43fd5096b2dedca8e295efe4f9","RELEASE_PROCESS.md":"a86cd10fc70f167f8d00e9e4ce0c6b4ebdfa1865058390dffd1e0ad4d3e68d9d","benches/bench.rs":"d67bef1c7f36ed300a8fbcf9d50b9dfdead1fd340bf87a4d47d99a0c1c042c04","src/algo.rs":"932c2bc591d13fe4470185125617b5aaa660a3898f23b553acc85df0bf49dded","src/lib.rs":"4acd41668fe30daffa37084e7e223f268957b816afc1864ffb3f5d6d7adf0890"},"package":"512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"}
\ No newline at end of file
+{"files":{".cargo_vcs_info.json":"08071a308400282ad18ca2de0df6d1f2dc270475f69aa483740ce311af3f63e0","CHANGELOG.md":"04fa29ec6eb6b05b706247ecac2cbc7075792dbfcea0bf52715782cf42132e94","Cargo.lock":"3e44ced212a9e7ddc0a5450bcebb48ec67f32a058529856458efa36415554e53","Cargo.toml":"8f30dbd092f3acc475b9d339736cd7b64c6489bc47cd234a7f2232fc52e2d490","Cargo.toml.orig":"077df9094ac86443a4d05305f74782bd237c1f15fa39640463e4c62e9e4a310a","LICENSE-0BSD":"861399f8c21c042b110517e76dc6b63a2b334276c8cf17412fc3c8908ca8dc17","LICENSE-APACHE":"8ada45cd9f843acf64e4722ae262c622a2b3b3007c7310ef36ac1061a30f6adb","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"cd955d5d6a49161e6f7a04df4a5963581b66ed43fd5096b2dedca8e295efe4f9","RELEASE_PROCESS.md":"a86cd10fc70f167f8d00e9e4ce0c6b4ebdfa1865058390dffd1e0ad4d3e68d9d","benches/bench.rs":"d67bef1c7f36ed300a8fbcf9d50b9dfdead1fd340bf87a4d47d99a0c1c042c04","src/algo.rs":"932c2bc591d13fe4470185125617b5aaa660a3898f23b553acc85df0bf49dded","src/lib.rs":"4acd41668fe30daffa37084e7e223f268957b816afc1864ffb3f5d6d7adf0890"},"package":"320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"}
\ No newline at end of file
diff --git a/external/vendor/adler2/.cargo_vcs_info.json b/external/vendor/adler2/.cargo_vcs_info.json
new file mode 100644
index 00000000..23ea6655
--- /dev/null
+++ b/external/vendor/adler2/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+ "git": {
+ "sha1": "89a031a0f42eeff31c70dc598b398cbf31f1680f"
+ },
+ "path_in_vcs": ""
+}
\ No newline at end of file
diff --git a/external/vendor/adler2/CHANGELOG.md b/external/vendor/adler2/CHANGELOG.md
index 9ddf18bc..60bf0df9 100644
--- a/external/vendor/adler2/CHANGELOG.md
+++ b/external/vendor/adler2/CHANGELOG.md
@@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
+---
+## [2.0.1](https://github.com/Frommi/miniz_oxide/compare/2.0.0..2.0.1) - 2025-06-09
+
+### Other
+
+- Remove `compiler-builtins` from `rustc-dep-of-std` dependencies - ([7cdbd39](https://github.com/Frommi/miniz_oxide/commit/7cdbd3925a7f61cc075f44367b5d383861571b0a)) - Trevor Gross
+
---
## [2.0.0](https://github.com/Frommi/miniz_oxide/compare/1.0.2..2.0.0) - 2024-08-04
diff --git a/external/vendor/adler2/Cargo.lock b/external/vendor/adler2/Cargo.lock
new file mode 100644
index 00000000..2a3d5675
--- /dev/null
+++ b/external/vendor/adler2/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "adler2"
+version = "2.0.1"
+dependencies = [
+ "rustc-std-workspace-core",
+]
+
+[[package]]
+name = "rustc-std-workspace-core"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c"
diff --git a/external/vendor/adler2/Cargo.toml b/external/vendor/adler2/Cargo.toml
index d8610a85..d137e3d9 100644
--- a/external/vendor/adler2/Cargo.toml
+++ b/external/vendor/adler2/Cargo.toml
@@ -12,12 +12,14 @@
[package]
edition = "2021"
name = "adler2"
-version = "2.0.0"
+version = "2.0.1"
authors = [
"Jonas Schievink <jonasschievink@gmail.com>",
"oyvindln <oyvindln@users.noreply.github.com>",
]
build = false
+exclude = [".*"]
+autolib = false
autobins = false
autoexamples = false
autotests = false
@@ -67,6 +69,11 @@ file = "src/lib.rs"
replace = "https://docs.rs/adler/{{version}}"
search = 'https://docs.rs/adler/[a-z0-9\.-]+'
+[features]
+default = ["std"]
+rustc-dep-of-std = ["core"]
+std = []
+
[lib]
name = "adler2"
path = "src/lib.rs"
@@ -76,22 +83,9 @@ name = "bench"
path = "benches/bench.rs"
harness = false
-[dependencies.compiler_builtins]
-version = "0.1.2"
-optional = true
-
[dependencies.core]
version = "1.0.0"
optional = true
package = "rustc-std-workspace-core"
-[dev-dependencies.criterion]
-version = "0.3.2"
-
-[features]
-default = ["std"]
-rustc-dep-of-std = [
- "core",
- "compiler_builtins",
-]
-std = []
+[dev-dependencies]
diff --git a/external/vendor/adler2/Cargo.toml.orig b/external/vendor/adler2/Cargo.toml.orig
new file mode 100644
index 00000000..78ffd9a9
--- /dev/null
+++ b/external/vendor/adler2/Cargo.toml.orig
@@ -0,0 +1,71 @@
+[package]
+name = "adler2"
+version = "2.0.1"
+authors = ["Jonas Schievink <jonasschievink@gmail.com>", "oyvindln <oyvindln@users.noreply.github.com>"]
+description = "A simple clean-room implementation of the Adler-32 checksum"
+documentation = "https://docs.rs/adler2/"
+repository = "https://github.com/oyvindln/adler2"
+keywords = ["checksum", "integrity", "hash", "adler32", "zlib"]
+categories = ["algorithms"]
+readme = "README.md"
+license = "0BSD OR MIT OR Apache-2.0"
+edition = "2021"
+exclude = [".*"]
+
+[[bench]]
+name = "bench"
+harness = false
+
+[dependencies]
+# Internal features, only used when building as part of libstd, not part of the
+# stable interface of this crate.
+core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
+
+[dev-dependencies]
+## Messes with minimum rust version and drags in deps just for running tests
+## so just comment out for now and enable manually when needed for enabling benches
+## criterion = "0.3.2"
+
+[features]
+# Disable default features to enable `#![no_std]` support.
+default = ["std"]
+std = []
+
+# Internal feature, only used when building as part of libstd, not part of the
+# stable interface of this crate.
+rustc-dep-of-std = ['core']
+
+
+[package.metadata.docs.rs]
+rustdoc-args = [ "--cfg=docsrs" ]
+
+# cargo-release configuration
+[package.metadata.release]
+tag-message = "{{version}}"
+no-dev-version = true
+pre-release-commit-message = "Release {{version}}"
+
+# Change the changelog's `Unreleased` section to refer to this release and
+# prepend a new `Unreleased` section
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = "## Unreleased\n"
+replace = """
+## Unreleased
+
+No changes.
+
+## [{{version}} - {{date}}](https://github.com/jonas-schievink/adler/releases/tag/v{{version}})
+"""
+
+# Bump the version inside the example manifest in `README.md`
+[[package.metadata.release.pre-release-replacements]]
+file = "README.md"
+search = 'adler = "[a-z0-9\\.-]+"'
+replace = 'adler = "{{version}}"'
+
+# Bump the version referenced by the `html_root_url` attribute in `lib.rs`
+[[package.metadata.release.pre-release-replacements]]
+file = "src/lib.rs"
+search = "https://docs.rs/adler/[a-z0-9\\.-]+"
+replace = "https://docs.rs/adler/{{version}}"
diff --git a/external/vendor/aead/.cargo-checksum.json b/external/vendor/aead/.cargo-checksum.json
index ce583216..96c5c495 100644
--- a/external/vendor/aead/.cargo-checksum.json
+++ b/external/vendor/aead/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"8870cb71cd8b46213591c7a4ee7ad80985600bd00c9f88331f825407498a00a7","Cargo.toml":"bf935971de51d6c168946e1822e1e4c3267aad0e1ae6e036b4e5baeb6d81a4be","LICENSE-APACHE":"b1cf9a3333ca78152b859012cd4a804156e5243e9ca20ad1df7327ba5ea7405c","LICENSE-MIT":"949ab7b3e7140fee216f06fe3a2bd67d68dd511f8ea73c1e01c98cb348e9c8ae","README.md":"8e195a2c3d0437b035de4640adabc6fb29ed91d814ec5073e7c2ae1a4d988748","src/dev.rs":"8a615fadb1236158cea9fde4ea96e8bb2ced4757c43b829c23eb143fc816d894","src/lib.rs":"477a851e2666a29dc3a724a75b7558d32d9ed7584364e1567dc6746c32a74fc5","src/stream.rs":"0b89b1e648972b2434cfed6556302f28ad2d8bdc11434f6905354167bf8a38e7"},"package":"d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"}
\ No newline at end of file
+{"files":{".cargo_vcs_info.json":"d25ef64c47aa2a16d9200724c0f56bddb4f5c24800986e070517867cfcdee0a4","CHANGELOG.md":"8870cb71cd8b46213591c7a4ee7ad80985600bd00c9f88331f825407498a00a7","Cargo.toml":"bf935971de51d6c168946e1822e1e4c3267aad0e1ae6e036b4e5baeb6d81a4be","Cargo.toml.orig":"c541eaa8f4355b379a5d3cf15e6ac710fde852fce72b5d5e9293f328d4f40622","LICENSE-APACHE":"b1cf9a3333ca78152b859012cd4a804156e5243e9ca20ad1df7327ba5ea7405c","LICENSE-MIT":"949ab7b3e7140fee216f06fe3a2bd67d68dd511f8ea73c1e01c98cb348e9c8ae","README.md":"8e195a2c3d0437b035de4640adabc6fb29ed91d814ec5073e7c2ae1a4d988748","src/dev.rs":"8a615fadb1236158cea9fde4ea96e8bb2ced4757c43b829c23eb143fc816d894","src/lib.rs":"477a851e2666a29dc3a724a75b7558d32d9ed7584364e1567dc6746c32a74fc5","src/stream.rs":"0b89b1e648972b2434cfed6556302f28ad2d8bdc11434f6905354167bf8a38e7"},"package":"d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"}
\ No newline at end of file
diff --git a/external/vendor/aead/.cargo_vcs_info.json b/external/vendor/aead/.cargo_vcs_info.json
new file mode 100644
index 00000000..588a8fa0
--- /dev/null
+++ b/external/vendor/aead/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+ "git": {
+ "sha1": "1ae238c527c204dd9590e3abc406cfbb342d46ea"
+ },
+ "path_in_vcs": "aead"
+}
\ No newline at end of file
diff --git a/external/vendor/aead/Cargo.toml.orig b/external/vendor/aead/Cargo.toml.orig
new file mode 100644
index 00000000..29eb0bf2
--- /dev/null
+++ b/external/vendor/aead/Cargo.toml.orig
@@ -0,0 +1,39 @@
+[package]
+name = "aead"
+version = "0.5.2"
+description = """
+Traits for Authenticated Encryption with Associated Data (AEAD) algorithms,
+such as AES-GCM as ChaCha20Poly1305, which provide a high-level API
+"""
+authors = ["RustCrypto Developers"]
+edition = "2021"
+license = "MIT OR Apache-2.0"
+readme = "README.md"
+documentation = "https://docs.rs/aead"
+repository = "https://github.com/RustCrypto/traits"
+keywords = ["crypto", "encryption"]
+categories = ["cryptography", "no-std"]
+rust-version = "1.56"
+
+[dependencies]
+crypto-common = "0.1.4"
+generic-array = { version = "0.14", default-features = false }
+
+# optional dependencies
+arrayvec = { version = "0.7", optional = true, default-features = false }
+blobby = { version = "0.3", optional = true }
+bytes = { version = "1", optional = true, default-features = false }
+heapless = { version = "0.7", optional = true, default-features = false }
+
+[features]
+default = ["rand_core"]
+alloc = []
+std = ["alloc", "crypto-common/std"]
+dev = ["blobby"]
+getrandom = ["crypto-common/getrandom", "rand_core"]
+rand_core = ["crypto-common/rand_core"]
+stream = []
+
+[package.metadata.docs.rs]
+all-features = true
+rustdoc-args = ["--cfg", "docsrs"]
diff --git a/external/vendor/allocator-api2/.cargo-checksum.json b/external/vendor/allocator-api2/.cargo-checksum.json
deleted file mode 100644
index 3714d70b..00000000
--- a/external/vendor/allocator-api2/.cargo-checksum.json
+++ /dev/null
@@ -1 +0,0 @@
-{"files":{"CHANGELOG.md":"886f8c688db0c22d24b650df0dc30a39d05d54d0e562c00d9574bf31cbf73251","Cargo.toml":"ddaa434cc54a30a33bbe0096e72479d71ba5deffa2ad9bee39419d4e50b75275","LICENSE-APACHE":"20fe7b00e904ed690e3b9fd6073784d3fc428141dbd10b81c01fd143d0797f58","LICENSE-MIT":"36516aefdc84c5d5a1e7485425913a22dbda69eb1930c5e84d6ae4972b5194b9","README.md":"8b8c45a89f9d61688fd32516ca24ea11cc6be4994757bd01bd9d02d96cd49337","src/lib.rs":"56a7344026bf5be503ca8b3fe208b74550956e82be7806a229951e80ebb3c249","src/nightly.rs":"c12152b6721216174c9a3cec90e612d5571a5d2c0a94ad54900cb814414519c3","src/stable/alloc/global.rs":"14836ad7d73a364474fc153b24a1f17ad0e60a69b90a8721dc1059eada8bf869","src/stable/alloc/mod.rs":"866dafd3984dd246e381d8ad1c2b3e02a60c3421b598ca493aa83f9b6422608d","src/stable/alloc/system.rs":"db5d5bf088eecac3fc5ff1281e1bf26ca36dd38f13cd52c49d95ff1bab064254","src/stable/boxed.rs":"fb664ab68a599b7fc5acbae1c634c2007ba2bda9a24fea2212b8202bb537f7a0","src/stable/macros.rs":"74490796a766338d0163f40a37612cd9ea2de58ae3d8e9abf6c7bcf81d9be4a6","src/stable/mod.rs":"474dce5f150456a98fa7c4debc24f03ec2db4ebf0d54011ae19c8b575feb5712","src/stable/raw_vec.rs":"9a56ce1bab4562000285e80837da7b7bd2bbbc63850c83ab5d8df9888b65f5db","src/stable/slice.rs":"089263b058e6c185467bad7ad14908479e5675408fc70a8291e5dddaef36035a","src/stable/unique.rs":"6ed3678beed7fa6bd18b694f7357e638d83e3f1f895f9988a465dc5afebfbac9","src/stable/vec/drain.rs":"740cd2e0f31eeb0146bbd0f645a14fe12bacd3912f003db433ddc6b3a178461f","src/stable/vec/into_iter.rs":"da72ce52344ea2e263ddf7776356cc012bbafc51f48499955c1771729448754d","src/stable/vec/mod.rs":"dd3ddca02747686ed2064397dd17068b64f28c6f42b55e9e2ce129cd573fe44c","src/stable/vec/partial_eq.rs":"9f1b18605164a62b58d9e17914d573698735de31c51ceb8bd3666e83d32df370","src/stable/vec/set_len_on_drop.rs":"561342e22a194e515cc25c9a1bcd827ca24c4db033e9e2c4266fbdd2fb16e5bc","src/stable/vec/splice.rs":"95a460b3a7b4af60fdc9ba04d3a719b61a0c11786cd2d8823d022e22c397f9c9"},"package":"683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"}
\ No newline at end of file
diff --git a/external/vendor/allocator-api2/CHANGELOG.md b/external/vendor/allocator-api2/CHANGELOG.md
deleted file mode 100644
index 1d8f11d3..00000000
--- a/external/vendor/allocator-api2/CHANGELOG.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [Unreleased]
diff --git a/external/vendor/allocator-api2/Cargo.toml b/external/vendor/allocator-api2/Cargo.toml
deleted file mode 100644
index 541b4e97..00000000
--- a/external/vendor/allocator-api2/Cargo.toml
+++ /dev/null
@@ -1,48 +0,0 @@
-# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
-#
-# When uploading crates to the registry Cargo will automatically
-# "normalize" Cargo.toml files for maximal compatibility
-# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies.
-#
-# If you are reading this file be aware that the original Cargo.toml
-# will likely look very different (and much more reasonable).
-# See Cargo.toml.orig for the original contents.
-
-[package]
-edition = "2018"
-rust-version = "1.63"
-name = "allocator-api2"
-version = "0.2.21"
-authors = ["Zakarum <zaq.dev@icloud.com>"]
-build = false
-autobins = false
-autoexamples = false
-autotests = false
-autobenches = false
-description = "Mirror of Rust's allocator API"
-homepage = "https://github.com/zakarumych/allocator-api2"
-documentation = "https://docs.rs/allocator-api2"
-readme = "README.md"
-license = "MIT OR Apache-2.0"
-repository = "https://github.com/zakarumych/allocator-api2"
-
-[lib]
-name = "allocator_api2"
-path = "src/lib.rs"
-
-[dependencies.serde]
-version = "1.0"
-optional = true
-
-[features]
-alloc = []
-default = ["std"]
-fresh-rust = []
-nightly = []
-std = ["alloc"]
-
-[lints.rust.unexpected_cfgs]
-level = "warn"
-priority = 0
-check-cfg = ["cfg(no_global_oom_handling)"]
diff --git a/external/vendor/allocator-api2/LICENSE-APACHE b/external/vendor/allocator-api2/LICENSE-APACHE
deleted file mode 100644
index a2ce4d97..00000000
--- a/external/vendor/allocator-api2/LICENSE-APACHE
+++ /dev/null
@@ -1,176 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
diff --git a/external/vendor/allocator-api2/LICENSE-MIT b/external/vendor/allocator-api2/LICENSE-MIT
deleted file mode 100644
index 458723b3..00000000
--- a/external/vendor/allocator-api2/LICENSE-MIT
+++ /dev/null
@@ -1,23 +0,0 @@
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/external/vendor/allocator-api2/README.md b/external/vendor/allocator-api2/README.md
deleted file mode 100644
index 68e9b36c..00000000
--- a/external/vendor/allocator-api2/README.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# allocator-api2
-
-[](https://crates.io/crates/allocator-api2)
-[](https://docs.rs/allocator-api2)
-[](https://github.com/zakarumych/allocator-api2/actions/workflows/badge.yml)
-[](COPYING)
-
-
-This crate mirrors types and traits from Rust's unstable [`allocator_api`]
-The intention of this crate is to serve as substitution for actual thing
-for libs when build on stable and beta channels.
-The target users are library authors who implement allocators or collection types
-that use allocators, or anyone else who wants using [`allocator_api`]
-
-The crate should be frequently updated with minor version bump.
-When [`allocator_api`] is stable this crate will get version `1.0` and simply
-re-export from `core`, `alloc` and `std`.
-
-The code is mostly verbatim copy from rust repository.
-Mostly attributes are removed.
-
-## Usage
-
-This paragraph describes how to use this crate correctly to ensure
-compatibility and interoperability on both stable and nightly channels.
-
-If you are writing a library that interacts with allocators API, you can
-add this crate as a dependency and use the types and traits from this
-crate instead of the ones in `core` or `alloc`.
-This will allow your library to compile on stable and beta channels.
-
-Your library *MAY* provide a feature that will enable "allocator-api2/nightly".
-When this feature is enabled, your library *MUST* enable
-unstable `#![feature(allocator_api)]` or it may not compile.
-If feature is not provided, your library may not be compatible with the
-rest of the users and cause compilation errors on nightly channel
-when some other crate enables "allocator-api2/nightly" feature.
-
-# Minimal Supported Rust Version (MSRV)
-
-This crate is guaranteed to compile on stable Rust 1.63 and up.
-A feature "fresh-rust" bumps the MSRV to unspecified higher version, but should be compatible with
-at least few latest stable releases. The feature enables some additional functionality:
-
-* `CStr` without "std" feature
-
-## License
-
-Licensed under either of
-
-* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
-* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
-
-at your option.
-
-## Contributions
-
-Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
-
-
-[`allocator_api`]: https://doc.rust-lang.org/unstable-book/library-features/allocator-api.html
diff --git a/external/vendor/allocator-api2/src/lib.rs b/external/vendor/allocator-api2/src/lib.rs
deleted file mode 100644
index f0974db8..00000000
--- a/external/vendor/allocator-api2/src/lib.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-//!
-//! allocator-api2 crate.
-//!
-#![cfg_attr(not(feature = "std"), no_std)]
-
-#[cfg(feature = "alloc")]
-extern crate alloc as alloc_crate;
-
-#[cfg(not(feature = "nightly"))]
-#[macro_use]
-mod stable;
-
-#[cfg(feature = "nightly")]
-mod nightly;
-
-#[cfg(not(feature = "nightly"))]
-pub use self::stable::*;
-
-#[cfg(feature = "nightly")]
-pub use self::nightly::*;
diff --git a/external/vendor/allocator-api2/src/nightly.rs b/external/vendor/allocator-api2/src/nightly.rs
deleted file mode 100644
index 61f1cafb..00000000
--- a/external/vendor/allocator-api2/src/nightly.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-#[cfg(not(feature = "alloc"))]
-pub use core::alloc;
-
-#[cfg(feature = "alloc")]
-pub use alloc_crate::{alloc, boxed, vec, collections};
diff --git a/external/vendor/allocator-api2/src/stable/alloc/global.rs b/external/vendor/allocator-api2/src/stable/alloc/global.rs
deleted file mode 100644
index 161f3c2c..00000000
--- a/external/vendor/allocator-api2/src/stable/alloc/global.rs
+++ /dev/null
@@ -1,187 +0,0 @@
-use core::ptr::NonNull;
-
-use alloc_crate::alloc::{alloc, alloc_zeroed, dealloc, realloc};
-
-use crate::stable::{assume, invalid_mut};
-
-use super::{AllocError, Allocator, Layout};
-
-/// The global memory allocator.
-///
-/// This type implements the [`Allocator`] trait by forwarding calls
-/// to the allocator registered with the `#[global_allocator]` attribute
-/// if there is one, or the `std` crate’s default.
-///
-/// Note: while this type is unstable, the functionality it provides can be
-/// accessed through the [free functions in `alloc`](crate#functions).
-#[derive(Copy, Clone, Default, Debug)]
-pub struct Global;
-
-impl Global {
- #[inline(always)]
- fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> {
- match layout.size() {
- 0 => Ok(unsafe {
- NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- invalid_mut(layout.align()),
- 0,
- ))
- }),
- // SAFETY: `layout` is non-zero in size,
- size => unsafe {
- let raw_ptr = if zeroed {
- alloc_zeroed(layout)
- } else {
- alloc(layout)
- };
- let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- ptr.as_ptr(),
- size,
- )))
- },
- }
- }
-
- // SAFETY: Same as `Allocator::grow`
- #[inline(always)]
- unsafe fn grow_impl(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- zeroed: bool,
- ) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() >= old_layout.size(),
- "`new_layout.size()` must be greater than or equal to `old_layout.size()`"
- );
-
- match old_layout.size() {
- 0 => self.alloc_impl(new_layout, zeroed),
-
- // SAFETY: `new_size` is non-zero as `old_size` is greater than or equal to `new_size`
- // as required by safety conditions. Other conditions must be upheld by the caller
- old_size if old_layout.align() == new_layout.align() => unsafe {
- let new_size = new_layout.size();
-
- // `realloc` probably checks for `new_size >= old_layout.size()` or something similar.
- assume(new_size >= old_layout.size());
-
- let raw_ptr = realloc(ptr.as_ptr(), old_layout, new_size);
- let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
- if zeroed {
- raw_ptr.add(old_size).write_bytes(0, new_size - old_size);
- }
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- ptr.as_ptr(),
- new_size,
- )))
- },
-
- // SAFETY: because `new_layout.size()` must be greater than or equal to `old_size`,
- // both the old and new memory allocation are valid for reads and writes for `old_size`
- // bytes. Also, because the old allocation wasn't yet deallocated, it cannot overlap
- // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
- // for `dealloc` must be upheld by the caller.
- old_size => unsafe {
- let new_ptr = self.alloc_impl(new_layout, zeroed)?;
- core::ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), old_size);
- self.deallocate(ptr, old_layout);
- Ok(new_ptr)
- },
- }
- }
-}
-
-unsafe impl Allocator for Global {
- #[inline(always)]
- fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- self.alloc_impl(layout, false)
- }
-
- #[inline(always)]
- fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- self.alloc_impl(layout, true)
- }
-
- #[inline(always)]
- unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
- if layout.size() != 0 {
- // SAFETY: `layout` is non-zero in size,
- // other conditions must be upheld by the caller
- unsafe { dealloc(ptr.as_ptr(), layout) }
- }
- }
-
- #[inline(always)]
- unsafe fn grow(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: all conditions must be upheld by the caller
- unsafe { self.grow_impl(ptr, old_layout, new_layout, false) }
- }
-
- #[inline(always)]
- unsafe fn grow_zeroed(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: all conditions must be upheld by the caller
- unsafe { self.grow_impl(ptr, old_layout, new_layout, true) }
- }
-
- #[inline(always)]
- unsafe fn shrink(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() <= old_layout.size(),
- "`new_layout.size()` must be smaller than or equal to `old_layout.size()`"
- );
-
- match new_layout.size() {
- // SAFETY: conditions must be upheld by the caller
- 0 => unsafe {
- self.deallocate(ptr, old_layout);
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- invalid_mut(new_layout.align()),
- 0,
- )))
- },
-
- // SAFETY: `new_size` is non-zero. Other conditions must be upheld by the caller
- new_size if old_layout.align() == new_layout.align() => unsafe {
- // `realloc` probably checks for `new_size <= old_layout.size()` or something similar.
- assume(new_size <= old_layout.size());
-
- let raw_ptr = realloc(ptr.as_ptr(), old_layout, new_size);
- let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- ptr.as_ptr(),
- new_size,
- )))
- },
-
- // SAFETY: because `new_size` must be smaller than or equal to `old_layout.size()`,
- // both the old and new memory allocation are valid for reads and writes for `new_size`
- // bytes. Also, because the old allocation wasn't yet deallocated, it cannot overlap
- // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
- // for `dealloc` must be upheld by the caller.
- new_size => unsafe {
- let new_ptr = self.allocate(new_layout)?;
- core::ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), new_size);
- self.deallocate(ptr, old_layout);
- Ok(new_ptr)
- },
- }
- }
-}
diff --git a/external/vendor/allocator-api2/src/stable/alloc/mod.rs b/external/vendor/allocator-api2/src/stable/alloc/mod.rs
deleted file mode 100644
index 35b389b9..00000000
--- a/external/vendor/allocator-api2/src/stable/alloc/mod.rs
+++ /dev/null
@@ -1,416 +0,0 @@
-//! Memory allocation APIs
-
-use core::{
- fmt,
- ptr::{self, NonNull},
-};
-
-#[cfg(feature = "alloc")]
-mod global;
-
-#[cfg(feature = "std")]
-mod system;
-
-pub use core::alloc::{GlobalAlloc, Layout, LayoutError};
-
-#[cfg(feature = "alloc")]
-pub use self::global::Global;
-
-#[cfg(feature = "std")]
-pub use self::system::System;
-
-#[cfg(feature = "alloc")]
-pub use alloc_crate::alloc::{alloc, alloc_zeroed, dealloc, realloc};
-
-#[cfg(all(feature = "alloc", not(no_global_oom_handling)))]
-pub use alloc_crate::alloc::handle_alloc_error;
-
-/// The `AllocError` error indicates an allocation failure
-/// that may be due to resource exhaustion or to
-/// something wrong when combining the given input arguments with this
-/// allocator.
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
-pub struct AllocError;
-
-#[cfg(feature = "std")]
-impl std::error::Error for AllocError {}
-
-// (we need this for downstream impl of trait Error)
-impl fmt::Display for AllocError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_str("memory allocation failed")
- }
-}
-
-/// An implementation of `Allocator` can allocate, grow, shrink, and deallocate arbitrary blocks of
-/// data described via [`Layout`][].
-///
-/// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers because having
-/// an allocator like `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the
-/// allocated memory.
-///
-/// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `Allocator`. If an underlying
-/// allocator does not support this (like jemalloc) or return a null pointer (such as
-/// `libc::malloc`), this must be caught by the implementation.
-///
-/// ### Currently allocated memory
-///
-/// Some of the methods require that a memory block be *currently allocated* via an allocator. This
-/// means that:
-///
-/// * the starting address for that memory block was previously returned by [`allocate`], [`grow`], or
-/// [`shrink`], and
-///
-/// * the memory block has not been subsequently deallocated, where blocks are either deallocated
-/// directly by being passed to [`deallocate`] or were changed by being passed to [`grow`] or
-/// [`shrink`] that returns `Ok`. If `grow` or `shrink` have returned `Err`, the passed pointer
-/// remains valid.
-///
-/// [`allocate`]: Allocator::allocate
-/// [`grow`]: Allocator::grow
-/// [`shrink`]: Allocator::shrink
-/// [`deallocate`]: Allocator::deallocate
-///
-/// ### Memory fitting
-///
-/// Some of the methods require that a layout *fit* a memory block. What it means for a layout to
-/// "fit" a memory block means (or equivalently, for a memory block to "fit" a layout) is that the
-/// following conditions must hold:
-///
-/// * The block must be allocated with the same alignment as [`layout.align()`], and
-///
-/// * The provided [`layout.size()`] must fall in the range `min ..= max`, where:
-/// - `min` is the size of the layout most recently used to allocate the block, and
-/// - `max` is the latest actual size returned from [`allocate`], [`grow`], or [`shrink`].
-///
-/// [`layout.align()`]: Layout::align
-/// [`layout.size()`]: Layout::size
-///
-/// # Safety
-///
-/// * Memory blocks returned from an allocator must point to valid memory and retain their validity
-/// until the instance and all of its clones are dropped,
-///
-/// * cloning or moving the allocator must not invalidate memory blocks returned from this
-/// allocator. A cloned allocator must behave like the same allocator, and
-///
-/// * any pointer to a memory block which is [*currently allocated*] may be passed to any other
-/// method of the allocator.
-///
-/// [*currently allocated*]: #currently-allocated-memory
-pub unsafe trait Allocator {
- /// Attempts to allocate a block of memory.
- ///
- /// On success, returns a [`NonNull<[u8]>`][NonNull] meeting the size and alignment guarantees of `layout`.
- ///
- /// The returned block may have a larger size than specified by `layout.size()`, and may or may
- /// not have its contents initialized.
- ///
- /// # Errors
- ///
- /// Returning `Err` indicates that either memory is exhausted or `layout` does not meet
- /// allocator's size or alignment constraints.
- ///
- /// Implementations are encouraged to return `Err` on memory exhaustion rather than panicking or
- /// aborting, but this is not a strict requirement. (Specifically: it is *legal* to implement
- /// this trait atop an underlying native allocation library that aborts on memory exhaustion.)
- ///
- /// Clients wishing to abort computation in response to an allocation error are encouraged to
- /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
- ///
- /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
- fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
-
- /// Behaves like `allocate`, but also ensures that the returned memory is zero-initialized.
- ///
- /// # Errors
- ///
- /// Returning `Err` indicates that either memory is exhausted or `layout` does not meet
- /// allocator's size or alignment constraints.
- ///
- /// Implementations are encouraged to return `Err` on memory exhaustion rather than panicking or
- /// aborting, but this is not a strict requirement. (Specifically: it is *legal* to implement
- /// this trait atop an underlying native allocation library that aborts on memory exhaustion.)
- ///
- /// Clients wishing to abort computation in response to an allocation error are encouraged to
- /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
- ///
- /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
- #[inline(always)]
- fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- let ptr = self.allocate(layout)?;
- // SAFETY: `alloc` returns a valid memory block
- unsafe { ptr.cast::<u8>().as_ptr().write_bytes(0, ptr.len()) }
- Ok(ptr)
- }
-
- /// Deallocates the memory referenced by `ptr`.
- ///
- /// # Safety
- ///
- /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator, and
- /// * `layout` must [*fit*] that block of memory.
- ///
- /// [*currently allocated*]: #currently-allocated-memory
- /// [*fit*]: #memory-fitting
- unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout);
-
- /// Attempts to extend the memory block.
- ///
- /// Returns a new [`NonNull<[u8]>`][NonNull] containing a pointer and the actual size of the allocated
- /// memory. The pointer is suitable for holding data described by `new_layout`. To accomplish
- /// this, the allocator may extend the allocation referenced by `ptr` to fit the new layout.
- ///
- /// If this returns `Ok`, then ownership of the memory block referenced by `ptr` has been
- /// transferred to this allocator. Any access to the old `ptr` is Undefined Behavior, even if the
- /// allocation was grown in-place. The newly returned pointer is the only valid pointer
- /// for accessing this memory now.
- ///
- /// If this method returns `Err`, then ownership of the memory block has not been transferred to
- /// this allocator, and the contents of the memory block are unaltered.
- ///
- /// # Safety
- ///
- /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator.
- /// * `old_layout` must [*fit*] that block of memory (The `new_layout` argument need not fit it.).
- /// * `new_layout.size()` must be greater than or equal to `old_layout.size()`.
- ///
- /// Note that `new_layout.align()` need not be the same as `old_layout.align()`.
- ///
- /// [*currently allocated*]: #currently-allocated-memory
- /// [*fit*]: #memory-fitting
- ///
- /// # Errors
- ///
- /// Returns `Err` if the new layout does not meet the allocator's size and alignment
- /// constraints of the allocator, or if growing otherwise fails.
- ///
- /// Implementations are encouraged to return `Err` on memory exhaustion rather than panicking or
- /// aborting, but this is not a strict requirement. (Specifically: it is *legal* to implement
- /// this trait atop an underlying native allocation library that aborts on memory exhaustion.)
- ///
- /// Clients wishing to abort computation in response to an allocation error are encouraged to
- /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
- ///
- /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
- #[inline(always)]
- unsafe fn grow(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() >= old_layout.size(),
- "`new_layout.size()` must be greater than or equal to `old_layout.size()`"
- );
-
- let new_ptr = self.allocate(new_layout)?;
-
- // SAFETY: because `new_layout.size()` must be greater than or equal to
- // `old_layout.size()`, both the old and new memory allocation are valid for reads and
- // writes for `old_layout.size()` bytes. Also, because the old allocation wasn't yet
- // deallocated, it cannot overlap `new_ptr`. Thus, the call to `copy_nonoverlapping` is
- // safe. The safety contract for `dealloc` must be upheld by the caller.
- unsafe {
- ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), old_layout.size());
- self.deallocate(ptr, old_layout);
- }
-
- Ok(new_ptr)
- }
-
- /// Behaves like `grow`, but also ensures that the new contents are set to zero before being
- /// returned.
- ///
- /// The memory block will contain the following contents after a successful call to
- /// `grow_zeroed`:
- /// * Bytes `0..old_layout.size()` are preserved from the original allocation.
- /// * Bytes `old_layout.size()..old_size` will either be preserved or zeroed, depending on
- /// the allocator implementation. `old_size` refers to the size of the memory block prior
- /// to the `grow_zeroed` call, which may be larger than the size that was originally
- /// requested when it was allocated.
- /// * Bytes `old_size..new_size` are zeroed. `new_size` refers to the size of the memory
- /// block returned by the `grow_zeroed` call.
- ///
- /// # Safety
- ///
- /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator.
- /// * `old_layout` must [*fit*] that block of memory (The `new_layout` argument need not fit it.).
- /// * `new_layout.size()` must be greater than or equal to `old_layout.size()`.
- ///
- /// Note that `new_layout.align()` need not be the same as `old_layout.align()`.
- ///
- /// [*currently allocated*]: #currently-allocated-memory
- /// [*fit*]: #memory-fitting
- ///
- /// # Errors
- ///
- /// Returns `Err` if the new layout does not meet the allocator's size and alignment
- /// constraints of the allocator, or if growing otherwise fails.
- ///
- /// Implementations are encouraged to return `Err` on memory exhaustion rather than panicking or
- /// aborting, but this is not a strict requirement. (Specifically: it is *legal* to implement
- /// this trait atop an underlying native allocation library that aborts on memory exhaustion.)
- ///
- /// Clients wishing to abort computation in response to an allocation error are encouraged to
- /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
- ///
- /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
- #[inline(always)]
- unsafe fn grow_zeroed(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() >= old_layout.size(),
- "`new_layout.size()` must be greater than or equal to `old_layout.size()`"
- );
-
- let new_ptr = self.allocate_zeroed(new_layout)?;
-
- // SAFETY: because `new_layout.size()` must be greater than or equal to
- // `old_layout.size()`, both the old and new memory allocation are valid for reads and
- // writes for `old_layout.size()` bytes. Also, because the old allocation wasn't yet
- // deallocated, it cannot overlap `new_ptr`. Thus, the call to `copy_nonoverlapping` is
- // safe. The safety contract for `dealloc` must be upheld by the caller.
- unsafe {
- ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), old_layout.size());
- self.deallocate(ptr, old_layout);
- }
-
- Ok(new_ptr)
- }
-
- /// Attempts to shrink the memory block.
- ///
- /// Returns a new [`NonNull<[u8]>`][NonNull] containing a pointer and the actual size of the allocated
- /// memory. The pointer is suitable for holding data described by `new_layout`. To accomplish
- /// this, the allocator may shrink the allocation referenced by `ptr` to fit the new layout.
- ///
- /// If this returns `Ok`, then ownership of the memory block referenced by `ptr` has been
- /// transferred to this allocator. Any access to the old `ptr` is Undefined Behavior, even if the
- /// allocation was shrunk in-place. The newly returned pointer is the only valid pointer
- /// for accessing this memory now.
- ///
- /// If this method returns `Err`, then ownership of the memory block has not been transferred to
- /// this allocator, and the contents of the memory block are unaltered.
- ///
- /// # Safety
- ///
- /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator.
- /// * `old_layout` must [*fit*] that block of memory (The `new_layout` argument need not fit it.).
- /// * `new_layout.size()` must be smaller than or equal to `old_layout.size()`.
- ///
- /// Note that `new_layout.align()` need not be the same as `old_layout.align()`.
- ///
- /// [*currently allocated*]: #currently-allocated-memory
- /// [*fit*]: #memory-fitting
- ///
- /// # Errors
- ///
- /// Returns `Err` if the new layout does not meet the allocator's size and alignment
- /// constraints of the allocator, or if shrinking otherwise fails.
- ///
- /// Implementations are encouraged to return `Err` on memory exhaustion rather than panicking or
- /// aborting, but this is not a strict requirement. (Specifically: it is *legal* to implement
- /// this trait atop an underlying native allocation library that aborts on memory exhaustion.)
- ///
- /// Clients wishing to abort computation in response to an allocation error are encouraged to
- /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
- ///
- /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
- #[inline(always)]
- unsafe fn shrink(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() <= old_layout.size(),
- "`new_layout.size()` must be smaller than or equal to `old_layout.size()`"
- );
-
- let new_ptr = self.allocate(new_layout)?;
-
- // SAFETY: because `new_layout.size()` must be lower than or equal to
- // `old_layout.size()`, both the old and new memory allocation are valid for reads and
- // writes for `new_layout.size()` bytes. Also, because the old allocation wasn't yet
- // deallocated, it cannot overlap `new_ptr`. Thus, the call to `copy_nonoverlapping` is
- // safe. The safety contract for `dealloc` must be upheld by the caller.
- unsafe {
- ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), new_layout.size());
- self.deallocate(ptr, old_layout);
- }
-
- Ok(new_ptr)
- }
-
- /// Creates a "by reference" adapter for this instance of `Allocator`.
- ///
- /// The returned adapter also implements `Allocator` and will simply borrow this.
- #[inline(always)]
- fn by_ref(&self) -> &Self
- where
- Self: Sized,
- {
- self
- }
-}
-
-unsafe impl<A> Allocator for &A
-where
- A: Allocator + ?Sized,
-{
- #[inline(always)]
- fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- (**self).allocate(layout)
- }
-
- #[inline(always)]
- fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- (**self).allocate_zeroed(layout)
- }
-
- #[inline(always)]
- unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
- // SAFETY: the safety contract must be upheld by the caller
- unsafe { (**self).deallocate(ptr, layout) }
- }
-
- #[inline(always)]
- unsafe fn grow(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: the safety contract must be upheld by the caller
- unsafe { (**self).grow(ptr, old_layout, new_layout) }
- }
-
- #[inline(always)]
- unsafe fn grow_zeroed(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: the safety contract must be upheld by the caller
- unsafe { (**self).grow_zeroed(ptr, old_layout, new_layout) }
- }
-
- #[inline(always)]
- unsafe fn shrink(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: the safety contract must be upheld by the caller
- unsafe { (**self).shrink(ptr, old_layout, new_layout) }
- }
-}
diff --git a/external/vendor/allocator-api2/src/stable/alloc/system.rs b/external/vendor/allocator-api2/src/stable/alloc/system.rs
deleted file mode 100644
index 3a0fe4c8..00000000
--- a/external/vendor/allocator-api2/src/stable/alloc/system.rs
+++ /dev/null
@@ -1,172 +0,0 @@
-use core::ptr::NonNull;
-pub use std::alloc::System;
-
-use crate::stable::{assume, invalid_mut};
-
-use super::{AllocError, Allocator, GlobalAlloc as _, Layout};
-
-unsafe impl Allocator for System {
- #[inline(always)]
- fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- alloc_impl(layout, false)
- }
-
- #[inline(always)]
- fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
- alloc_impl(layout, true)
- }
-
- #[inline(always)]
- unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
- if layout.size() != 0 {
- // SAFETY: `layout` is non-zero in size,
- // other conditions must be upheld by the caller
- unsafe { System.dealloc(ptr.as_ptr(), layout) }
- }
- }
-
- #[inline(always)]
- unsafe fn grow(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: all conditions must be upheld by the caller
- unsafe { grow_impl(ptr, old_layout, new_layout, false) }
- }
-
- #[inline(always)]
- unsafe fn grow_zeroed(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- // SAFETY: all conditions must be upheld by the caller
- unsafe { grow_impl(ptr, old_layout, new_layout, true) }
- }
-
- #[inline(always)]
- unsafe fn shrink(
- &self,
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- ) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() <= old_layout.size(),
- "`new_layout.size()` must be smaller than or equal to `old_layout.size()`"
- );
-
- match new_layout.size() {
- // SAFETY: conditions must be upheld by the caller
- 0 => unsafe {
- self.deallocate(ptr, old_layout);
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- invalid_mut(new_layout.align()),
- 0,
- )))
- },
-
- // SAFETY: `new_size` is non-zero. Other conditions must be upheld by the caller
- new_size if old_layout.align() == new_layout.align() => unsafe {
- // `realloc` probably checks for `new_size <= old_layout.size()` or something similar.
- assume(new_size <= old_layout.size());
-
- let raw_ptr = System.realloc(ptr.as_ptr(), old_layout, new_size);
- let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- ptr.as_ptr(),
- new_size,
- )))
- },
-
- // SAFETY: because `new_size` must be smaller than or equal to `old_layout.size()`,
- // both the old and new memory allocation are valid for reads and writes for `new_size`
- // bytes. Also, because the old allocation wasn't yet deallocated, it cannot overlap
- // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
- // for `dealloc` must be upheld by the caller.
- new_size => unsafe {
- let new_ptr = self.allocate(new_layout)?;
- core::ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), new_size);
- self.deallocate(ptr, old_layout);
- Ok(new_ptr)
- },
- }
- }
-}
-
-#[inline(always)]
-fn alloc_impl(layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> {
- match layout.size() {
- 0 => Ok(unsafe {
- NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- invalid_mut(layout.align()),
- 0,
- ))
- }),
- // SAFETY: `layout` is non-zero in size,
- size => unsafe {
- let raw_ptr = if zeroed {
- System.alloc_zeroed(layout)
- } else {
- System.alloc(layout)
- };
- let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- ptr.as_ptr(),
- size,
- )))
- },
- }
-}
-
-// SAFETY: Same as `Allocator::grow`
-#[inline(always)]
-unsafe fn grow_impl(
- ptr: NonNull<u8>,
- old_layout: Layout,
- new_layout: Layout,
- zeroed: bool,
-) -> Result<NonNull<[u8]>, AllocError> {
- debug_assert!(
- new_layout.size() >= old_layout.size(),
- "`new_layout.size()` must be greater than or equal to `old_layout.size()`"
- );
-
- match old_layout.size() {
- 0 => alloc_impl(new_layout, zeroed),
-
- // SAFETY: `new_size` is non-zero as `old_size` is greater than or equal to `new_size`
- // as required by safety conditions. Other conditions must be upheld by the caller
- old_size if old_layout.align() == new_layout.align() => unsafe {
- let new_size = new_layout.size();
-
- // `realloc` probably checks for `new_size >= old_layout.size()` or something similar.
- assume(new_size >= old_layout.size());
-
- let raw_ptr = System.realloc(ptr.as_ptr(), old_layout, new_size);
- let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?;
- if zeroed {
- raw_ptr.add(old_size).write_bytes(0, new_size - old_size);
- }
- Ok(NonNull::new_unchecked(core::ptr::slice_from_raw_parts_mut(
- ptr.as_ptr(),
- new_size,
- )))
- },
-
- // SAFETY: because `new_layout.size()` must be greater than or equal to `old_size`,
- // both the old and new memory allocation are valid for reads and writes for `old_size`
- // bytes. Also, because the old allocation wasn't yet deallocated, it cannot overlap
- // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
- // for `dealloc` must be upheld by the caller.
- old_size => unsafe {
- let new_ptr = alloc_impl(new_layout, zeroed)?;
- core::ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_ptr().cast(), old_size);
- System.deallocate(ptr, old_layout);
- Ok(new_ptr)
- },
- }
-}
diff --git a/external/vendor/allocator-api2/src/stable/boxed.rs b/external/vendor/allocator-api2/src/stable/boxed.rs
deleted file mode 100644
index 8f963382..00000000
--- a/external/vendor/allocator-api2/src/stable/boxed.rs
+++ /dev/null
@@ -1,2272 +0,0 @@
-//! The `Box<T>` type for heap allocation.
-//!
-//! [`Box<T>`], casually referred to as a 'box', provides the simplest form of
-//! heap allocation in Rust. Boxes provide ownership for this allocation, and
-//! drop their contents when they go out of scope. Boxes also ensure that they
-//! never allocate more than `isize::MAX` bytes.
-//!
-//! # Examples
-//!
-//! Move a value from the stack to the heap by creating a [`Box`]:
-//!
-//! ```
-//! let val: u8 = 5;
-//! let boxed: Box<u8> = Box::new(val);
-//! ```
-//!
-//! Move a value from a [`Box`] back to the stack by [dereferencing]:
-//!
-//! ```
-//! let boxed: Box<u8> = Box::new(5);
-//! let val: u8 = *boxed;
-//! ```
-//!
-//! Creating a recursive data structure:
-//!
-//! ```
-//! #[derive(Debug)]
-//! enum List<T> {
-//! Cons(T, Box<List<T>>),
-//! Nil,
-//! }
-//!
-//! let list: List<i32> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Nil))));
-//! println!("{list:?}");
-//! ```
-//!
-//! This will print `Cons(1, Cons(2, Nil))`.
-//!
-//! Recursive structures must be boxed, because if the definition of `Cons`
-//! looked like this:
-//!
-//! ```compile_fail,E0072
-//! # enum List<T> {
-//! Cons(T, List<T>),
-//! # }
-//! ```
-//!
-//! It wouldn't work. This is because the size of a `List` depends on how many
-//! elements are in the list, and so we don't know how much memory to allocate
-//! for a `Cons`. By introducing a [`Box<T>`], which has a defined size, we know how
-//! big `Cons` needs to be.
-//!
-//! # Memory layout
-//!
-//! For non-zero-sized values, a [`Box`] will use the [`Global`] allocator for
-//! its allocation. It is valid to convert both ways between a [`Box`] and a
-//! raw pointer allocated with the [`Global`] allocator, given that the
-//! [`Layout`] used with the allocator is correct for the type. More precisely,
-//! a `value: *mut T` that has been allocated with the [`Global`] allocator
-//! with `Layout::for_value(&*value)` may be converted into a box using
-//! [`Box::<T>::from_raw(value)`]. Conversely, the memory backing a `value: *mut
-//! T` obtained from [`Box::<T>::into_raw`] may be deallocated using the
-//! [`Global`] allocator with [`Layout::for_value(&*value)`].
-//!
-//! For zero-sized values, the `Box` pointer still has to be [valid] for reads
-//! and writes and sufficiently aligned. In particular, casting any aligned
-//! non-zero integer literal to a raw pointer produces a valid pointer, but a
-//! pointer pointing into previously allocated memory that since got freed is
-//! not valid. The recommended way to build a Box to a ZST if `Box::new` cannot
-//! be used is to use [`ptr::NonNull::dangling`].
-//!
-//! So long as `T: Sized`, a `Box<T>` is guaranteed to be represented
-//! as a single pointer and is also ABI-compatible with C pointers
-//! (i.e. the C type `T*`). This means that if you have extern "C"
-//! Rust functions that will be called from C, you can define those
-//! Rust functions using `Box<T>` types, and use `T*` as corresponding
-//! type on the C side. As an example, consider this C header which
-//! declares functions that create and destroy some kind of `Foo`
-//! value:
-//!
-//! ```c
-//! /* C header */
-//!
-//! /* Returns ownership to the caller */
-//! struct Foo* foo_new(void);
-//!
-//! /* Takes ownership from the caller; no-op when invoked with null */
-//! void foo_delete(struct Foo*);
-//! ```
-//!
-//! These two functions might be implemented in Rust as follows. Here, the
-//! `struct Foo*` type from C is translated to `Box<Foo>`, which captures
-//! the ownership constraints. Note also that the nullable argument to
-//! `foo_delete` is represented in Rust as `Option<Box<Foo>>`, since `Box<Foo>`
-//! cannot be null.
-//!
-//! ```
-//! #[repr(C)]
-//! pub struct Foo;
-//!
-//! #[no_mangle]
-//! pub extern "C" fn foo_new() -> Box<Foo> {
-//! Box::new(Foo)
-//! }
-//!
-//! #[no_mangle]
-//! pub extern "C" fn foo_delete(_: Option<Box<Foo>>) {}
-//! ```
-//!
-//! Even though `Box<T>` has the same representation and C ABI as a C pointer,
-//! this does not mean that you can convert an arbitrary `T*` into a `Box<T>`
-//! and expect things to work. `Box<T>` values will always be fully aligned,
-//! non-null pointers. Moreover, the destructor for `Box<T>` will attempt to
-//! free the value with the global allocator. In general, the best practice
-//! is to only use `Box<T>` for pointers that originated from the global
-//! allocator.
-//!
-//! **Important.** At least at present, you should avoid using
-//! `Box<T>` types for functions that are defined in C but invoked
-//! from Rust. In those cases, you should directly mirror the C types
-//! as closely as possible. Using types like `Box<T>` where the C
-//! definition is just using `T*` can lead to undefined behavior, as
-//! described in [rust-lang/unsafe-code-guidelines#198][ucg#198].
-//!
-//! # Considerations for unsafe code
-//!
-//! **Warning: This section is not normative and is subject to change, possibly
-//! being relaxed in the future! It is a simplified summary of the rules
-//! currently implemented in the compiler.**
-//!
-//! The aliasing rules for `Box<T>` are the same as for `&mut T`. `Box<T>`
-//! asserts uniqueness over its content. Using raw pointers derived from a box
-//! after that box has been mutated through, moved or borrowed as `&mut T`
-//! is not allowed. For more guidance on working with box from unsafe code, see
-//! [rust-lang/unsafe-code-guidelines#326][ucg#326].
-//!
-//!
-//! [ucg#198]: https://github.com/rust-lang/unsafe-code-guidelines/issues/198
-//! [ucg#326]: https://github.com/rust-lang/unsafe-code-guidelines/issues/326
-//! [dereferencing]: core::ops::Deref
-//! [`Box::<T>::from_raw(value)`]: Box::from_raw
-//! [`Global`]: crate::alloc::Global
-//! [`Layout`]: crate::alloc::Layout
-//! [`Layout::for_value(&*value)`]: crate::alloc::Layout::for_value
-//! [valid]: ptr#safety
-
-use core::any::Any;
-use core::borrow;
-use core::cmp::Ordering;
-use core::convert::{From, TryFrom};
-
-// use core::error::Error;
-use core::fmt;
-use core::future::Future;
-use core::hash::{Hash, Hasher};
-#[cfg(not(no_global_oom_handling))]
-use core::iter::FromIterator;
-use core::iter::{FusedIterator, Iterator};
-use core::marker::Unpin;
-use core::mem::{self, MaybeUninit};
-use core::ops::{Deref, DerefMut};
-use core::pin::Pin;
-use core::ptr::{self, NonNull};
-use core::task::{Context, Poll};
-
-use super::alloc::{AllocError, Allocator, Global, Layout};
-use super::raw_vec::RawVec;
-use super::unique::Unique;
-#[cfg(not(no_global_oom_handling))]
-use super::vec::Vec;
-#[cfg(not(no_global_oom_handling))]
-use alloc_crate::alloc::handle_alloc_error;
-
-/// A pointer type for heap allocation.
-///
-/// See the [module-level documentation](../../std/boxed/index.html) for more.
-pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);
-
-// Safety: Box owns both T and A, so sending is safe if
-// sending is safe for T and A.
-unsafe impl<T: ?Sized, A: Allocator> Send for Box<T, A>
-where
- T: Send,
- A: Send,
-{
-}
-
-// Safety: Box owns both T and A, so sharing is safe if
-// sharing is safe for T and A.
-unsafe impl<T: ?Sized, A: Allocator> Sync for Box<T, A>
-where
- T: Sync,
- A: Sync,
-{
-}
-
-impl<T> Box<T> {
- /// Allocates memory on the heap and then places `x` into it.
- ///
- /// This doesn't actually allocate if `T` is zero-sized.
- ///
- /// # Examples
- ///
- /// ```
- /// let five = Box::new(5);
- /// ```
- #[cfg(all(not(no_global_oom_handling)))]
- #[inline(always)]
- #[must_use]
- pub fn new(x: T) -> Self {
- Self::new_in(x, Global)
- }
-
- /// Constructs a new box with uninitialized contents.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let mut five = Box::<u32>::new_uninit();
- ///
- /// let five = unsafe {
- /// // Deferred initialization:
- /// five.as_mut_ptr().write(5);
- ///
- /// five.assume_init()
- /// };
- ///
- /// assert_eq!(*five, 5)
- /// ```
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_uninit() -> Box<mem::MaybeUninit<T>> {
- Self::new_uninit_in(Global)
- }
-
- /// Constructs a new `Box` with uninitialized contents, with the memory
- /// being filled with `0` bytes.
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let zero = Box::<u32>::new_zeroed();
- /// let zero = unsafe { zero.assume_init() };
- ///
- /// assert_eq!(*zero, 0)
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
- Self::new_zeroed_in(Global)
- }
-
- /// Constructs a new `Pin<Box<T>>`. If `T` does not implement [`Unpin`], then
- /// `x` will be pinned in memory and unable to be moved.
- ///
- /// Constructing and pinning of the `Box` can also be done in two steps: `Box::pin(x)`
- /// does the same as <code>[Box::into_pin]\([Box::new]\(x))</code>. Consider using
- /// [`into_pin`](Box::into_pin) if you already have a `Box<T>`, or if you want to
- /// construct a (pinned) `Box` in a different way than with [`Box::new`].
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn pin(x: T) -> Pin<Box<T>> {
- Box::new(x).into()
- }
-
- /// Allocates memory on the heap then places `x` into it,
- /// returning an error if the allocation fails
- ///
- /// This doesn't actually allocate if `T` is zero-sized.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api)]
- ///
- /// let five = Box::try_new(5)?;
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- #[inline(always)]
- pub fn try_new(x: T) -> Result<Self, AllocError> {
- Self::try_new_in(x, Global)
- }
-
- /// Constructs a new box with uninitialized contents on the heap,
- /// returning an error if the allocation fails
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// let mut five = Box::<u32>::try_new_uninit()?;
- ///
- /// let five = unsafe {
- /// // Deferred initialization:
- /// five.as_mut_ptr().write(5);
- ///
- /// five.assume_init()
- /// };
- ///
- /// assert_eq!(*five, 5);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- #[inline(always)]
- pub fn try_new_uninit() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
- Box::try_new_uninit_in(Global)
- }
-
- /// Constructs a new `Box` with uninitialized contents, with the memory
- /// being filled with `0` bytes on the heap
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// let zero = Box::<u32>::try_new_zeroed()?;
- /// let zero = unsafe { zero.assume_init() };
- ///
- /// assert_eq!(*zero, 0);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[inline(always)]
- pub fn try_new_zeroed() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
- Box::try_new_zeroed_in(Global)
- }
-}
-
-impl<T, A: Allocator> Box<T, A> {
- /// Allocates memory in the given allocator then places `x` into it.
- ///
- /// This doesn't actually allocate if `T` is zero-sized.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api)]
- ///
- /// use std::alloc::System;
- ///
- /// let five = Box::new_in(5, System);
- /// ```
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_in(x: T, alloc: A) -> Self
- where
- A: Allocator,
- {
- let mut boxed = Self::new_uninit_in(alloc);
- unsafe {
- boxed.as_mut_ptr().write(x);
- boxed.assume_init()
- }
- }
-
- /// Allocates memory in the given allocator then places `x` into it,
- /// returning an error if the allocation fails
- ///
- /// This doesn't actually allocate if `T` is zero-sized.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api)]
- ///
- /// use std::alloc::System;
- ///
- /// let five = Box::try_new_in(5, System)?;
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- #[inline(always)]
- pub fn try_new_in(x: T, alloc: A) -> Result<Self, AllocError>
- where
- A: Allocator,
- {
- let mut boxed = Self::try_new_uninit_in(alloc)?;
- unsafe {
- boxed.as_mut_ptr().write(x);
- Ok(boxed.assume_init())
- }
- }
-
- /// Constructs a new box with uninitialized contents in the provided allocator.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let mut five = Box::<u32, _>::new_uninit_in(System);
- ///
- /// let five = unsafe {
- /// // Deferred initialization:
- /// five.as_mut_ptr().write(5);
- ///
- /// five.assume_init()
- /// };
- ///
- /// assert_eq!(*five, 5)
- /// ```
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- // #[unstable(feature = "new_uninit", issue = "63291")]
- #[inline(always)]
- pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
- where
- A: Allocator,
- {
- let layout = Layout::new::<mem::MaybeUninit<T>>();
- // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
- // That would make code size bigger.
- match Box::try_new_uninit_in(alloc) {
- Ok(m) => m,
- Err(_) => handle_alloc_error(layout),
- }
- }
-
- /// Constructs a new box with uninitialized contents in the provided allocator,
- /// returning an error if the allocation fails
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let mut five = Box::<u32, _>::try_new_uninit_in(System)?;
- ///
- /// let five = unsafe {
- /// // Deferred initialization:
- /// five.as_mut_ptr().write(5);
- ///
- /// five.assume_init()
- /// };
- ///
- /// assert_eq!(*five, 5);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- #[inline(always)]
- pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
- where
- A: Allocator,
- {
- let ptr = if mem::size_of::<T>() == 0 {
- NonNull::dangling()
- } else {
- let layout = Layout::new::<mem::MaybeUninit<T>>();
- alloc.allocate(layout)?.cast()
- };
-
- unsafe { Ok(Box::from_raw_in(ptr.as_ptr(), alloc)) }
- }
-
- /// Constructs a new `Box` with uninitialized contents, with the memory
- /// being filled with `0` bytes in the provided allocator.
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let zero = Box::<u32, _>::new_zeroed_in(System);
- /// let zero = unsafe { zero.assume_init() };
- ///
- /// assert_eq!(*zero, 0)
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[cfg(not(no_global_oom_handling))]
- // #[unstable(feature = "new_uninit", issue = "63291")]
- #[must_use]
- #[inline(always)]
- pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
- where
- A: Allocator,
- {
- let layout = Layout::new::<mem::MaybeUninit<T>>();
- // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
- // That would make code size bigger.
- match Box::try_new_zeroed_in(alloc) {
- Ok(m) => m,
- Err(_) => handle_alloc_error(layout),
- }
- }
-
- /// Constructs a new `Box` with uninitialized contents, with the memory
- /// being filled with `0` bytes in the provided allocator,
- /// returning an error if the allocation fails,
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let zero = Box::<u32, _>::try_new_zeroed_in(System)?;
- /// let zero = unsafe { zero.assume_init() };
- ///
- /// assert_eq!(*zero, 0);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[inline(always)]
- pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
- where
- A: Allocator,
- {
- let ptr = if mem::size_of::<T>() == 0 {
- NonNull::dangling()
- } else {
- let layout = Layout::new::<mem::MaybeUninit<T>>();
- alloc.allocate_zeroed(layout)?.cast()
- };
- unsafe { Ok(Box::from_raw_in(ptr.as_ptr(), alloc)) }
- }
-
- /// Constructs a new `Pin<Box<T, A>>`. If `T` does not implement [`Unpin`], then
- /// `x` will be pinned in memory and unable to be moved.
- ///
- /// Constructing and pinning of the `Box` can also be done in two steps: `Box::pin_in(x, alloc)`
- /// does the same as <code>[Box::into_pin]\([Box::new_in]\(x, alloc))</code>. Consider using
- /// [`into_pin`](Box::into_pin) if you already have a `Box<T, A>`, or if you want to
- /// construct a (pinned) `Box` in a different way than with [`Box::new_in`].
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn pin_in(x: T, alloc: A) -> Pin<Self>
- where
- A: 'static + Allocator,
- {
- Self::into_pin(Self::new_in(x, alloc))
- }
-
- /// Converts a `Box<T>` into a `Box<[T]>`
- ///
- /// This conversion does not allocate on the heap and happens in place.
- #[inline(always)]
- pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
- let (raw, alloc) = Box::into_raw_with_allocator(boxed);
- unsafe { Box::from_raw_in(raw as *mut [T; 1], alloc) }
- }
-
- /// Consumes the `Box`, returning the wrapped value.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(box_into_inner)]
- ///
- /// let c = Box::new(5);
- ///
- /// assert_eq!(Box::into_inner(c), 5);
- /// ```
- #[inline(always)]
- pub fn into_inner(boxed: Self) -> T {
- // Override our default `Drop` implementation.
- // Though the default `Drop` implementation drops the both the pointer and the allocator,
- // here we only want to drop the allocator.
- let boxed = mem::ManuallyDrop::new(boxed);
- let alloc = unsafe { ptr::read(&boxed.1) };
-
- let ptr = boxed.0;
- let unboxed = unsafe { ptr.as_ptr().read() };
- unsafe { alloc.deallocate(ptr.as_non_null_ptr().cast(), Layout::new::<T>()) };
-
- unboxed
- }
-}
-
-impl<T> Box<[T]> {
- /// Constructs a new boxed slice with uninitialized contents.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let mut values = Box::<[u32]>::new_uninit_slice(3);
- ///
- /// let values = unsafe {
- /// // Deferred initialization:
- /// values[0].as_mut_ptr().write(1);
- /// values[1].as_mut_ptr().write(2);
- /// values[2].as_mut_ptr().write(3);
- ///
- /// values.assume_init()
- /// };
- ///
- /// assert_eq!(*values, [1, 2, 3])
- /// ```
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
- unsafe { RawVec::with_capacity(len).into_box(len) }
- }
-
- /// Constructs a new boxed slice with uninitialized contents, with the memory
- /// being filled with `0` bytes.
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let values = Box::<[u32]>::new_zeroed_slice(3);
- /// let values = unsafe { values.assume_init() };
- ///
- /// assert_eq!(*values, [0, 0, 0])
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
- unsafe { RawVec::with_capacity_zeroed(len).into_box(len) }
- }
-
- /// Constructs a new boxed slice with uninitialized contents. Returns an error if
- /// the allocation fails
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// let mut values = Box::<[u32]>::try_new_uninit_slice(3)?;
- /// let values = unsafe {
- /// // Deferred initialization:
- /// values[0].as_mut_ptr().write(1);
- /// values[1].as_mut_ptr().write(2);
- /// values[2].as_mut_ptr().write(3);
- /// values.assume_init()
- /// };
- ///
- /// assert_eq!(*values, [1, 2, 3]);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- #[inline(always)]
- pub fn try_new_uninit_slice(len: usize) -> Result<Box<[mem::MaybeUninit<T>]>, AllocError> {
- Self::try_new_uninit_slice_in(len, Global)
- }
-
- /// Constructs a new boxed slice with uninitialized contents, with the memory
- /// being filled with `0` bytes. Returns an error if the allocation fails
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// let values = Box::<[u32]>::try_new_zeroed_slice(3)?;
- /// let values = unsafe { values.assume_init() };
- ///
- /// assert_eq!(*values, [0, 0, 0]);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[inline(always)]
- pub fn try_new_zeroed_slice(len: usize) -> Result<Box<[mem::MaybeUninit<T>]>, AllocError> {
- Self::try_new_zeroed_slice_in(len, Global)
- }
-}
-
-impl<T, A: Allocator> Box<[T], A> {
- /// Constructs a new boxed slice with uninitialized contents in the provided allocator.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let mut values = Box::<[u32], _>::new_uninit_slice_in(3, System);
- ///
- /// let values = unsafe {
- /// // Deferred initialization:
- /// values[0].as_mut_ptr().write(1);
- /// values[1].as_mut_ptr().write(2);
- /// values[2].as_mut_ptr().write(3);
- ///
- /// values.assume_init()
- /// };
- ///
- /// assert_eq!(*values, [1, 2, 3])
- /// ```
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
- unsafe { RawVec::with_capacity_in(len, alloc).into_box(len) }
- }
-
- /// Constructs a new boxed slice with uninitialized contents in the provided allocator,
- /// with the memory being filled with `0` bytes.
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let values = Box::<[u32], _>::new_zeroed_slice_in(3, System);
- /// let values = unsafe { values.assume_init() };
- ///
- /// assert_eq!(*values, [0, 0, 0])
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
- unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) }
- }
-
- /// Constructs a new boxed slice with uninitialized contents in the provided allocator. Returns an error if
- /// the allocation fails.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let mut values = Box::<[u32], _>::try_new_uninit_slice_in(3, System)?;
- /// let values = unsafe {
- /// // Deferred initialization:
- /// values[0].as_mut_ptr().write(1);
- /// values[1].as_mut_ptr().write(2);
- /// values[2].as_mut_ptr().write(3);
- /// values.assume_init()
- /// };
- ///
- /// assert_eq!(*values, [1, 2, 3]);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- #[inline]
- pub fn try_new_uninit_slice_in(
- len: usize,
- alloc: A,
- ) -> Result<Box<[MaybeUninit<T>], A>, AllocError> {
- let ptr = if mem::size_of::<T>() == 0 || len == 0 {
- NonNull::dangling()
- } else {
- let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
- Ok(l) => l,
- Err(_) => return Err(AllocError),
- };
- alloc.allocate(layout)?.cast()
- };
- unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
- }
-
- /// Constructs a new boxed slice with uninitialized contents in the provided allocator, with the memory
- /// being filled with `0` bytes. Returns an error if the allocation fails.
- ///
- /// See [`MaybeUninit::zeroed`][zeroed] for examples of correct and incorrect usage
- /// of this method.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api, new_uninit)]
- ///
- /// use std::alloc::System;
- ///
- /// let values = Box::<[u32], _>::try_new_zeroed_slice_in(3, System)?;
- /// let values = unsafe { values.assume_init() };
- ///
- /// assert_eq!(*values, [0, 0, 0]);
- /// # Ok::<(), std::alloc::AllocError>(())
- /// ```
- ///
- /// [zeroed]: mem::MaybeUninit::zeroed
- #[inline]
- pub fn try_new_zeroed_slice_in(
- len: usize,
- alloc: A,
- ) -> Result<Box<[mem::MaybeUninit<T>], A>, AllocError> {
- let ptr = if mem::size_of::<T>() == 0 || len == 0 {
- NonNull::dangling()
- } else {
- let layout = match Layout::array::<mem::MaybeUninit<T>>(len) {
- Ok(l) => l,
- Err(_) => return Err(AllocError),
- };
- alloc.allocate_zeroed(layout)?.cast()
- };
- unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
- }
-
- /// Converts `self` into a vector without clones or allocation.
- ///
- /// The resulting vector can be converted back into a box via
- /// `Vec<T>`'s `into_boxed_slice` method.
- ///
- /// # Examples
- ///
- /// ```
- /// let s: Box<[i32]> = Box::new([10, 40, 30]);
- /// let x = s.into_vec();
- /// // `s` cannot be used anymore because it has been converted into `x`.
- ///
- /// assert_eq!(x, vec![10, 40, 30]);
- /// ```
- #[inline]
- pub fn into_vec(self) -> Vec<T, A>
- where
- A: Allocator,
- {
- unsafe {
- let len = self.len();
- let (b, alloc) = Box::into_raw_with_allocator(self);
- Vec::from_raw_parts_in(b as *mut T, len, len, alloc)
- }
- }
-}
-
-impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
- /// Converts to `Box<T, A>`.
- ///
- /// # Safety
- ///
- /// As with [`MaybeUninit::assume_init`],
- /// it is up to the caller to guarantee that the value
- /// really is in an initialized state.
- /// Calling this when the content is not yet fully initialized
- /// causes immediate undefined behavior.
- ///
- /// [`MaybeUninit::assume_init`]: mem::MaybeUninit::assume_init
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let mut five = Box::<u32>::new_uninit();
- ///
- /// let five: Box<u32> = unsafe {
- /// // Deferred initialization:
- /// five.as_mut_ptr().write(5);
- ///
- /// five.assume_init()
- /// };
- ///
- /// assert_eq!(*five, 5)
- /// ```
- #[inline(always)]
- pub unsafe fn assume_init(self) -> Box<T, A> {
- let (raw, alloc) = Self::into_raw_with_allocator(self);
- unsafe { Box::<T, A>::from_raw_in(raw as *mut T, alloc) }
- }
-
- /// Writes the value and converts to `Box<T, A>`.
- ///
- /// This method converts the box similarly to [`Box::assume_init`] but
- /// writes `value` into it before conversion thus guaranteeing safety.
- /// In some scenarios use of this method may improve performance because
- /// the compiler may be able to optimize copying from stack.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let big_box = Box::<[usize; 1024]>::new_uninit();
- ///
- /// let mut array = [0; 1024];
- /// for (i, place) in array.iter_mut().enumerate() {
- /// *place = i;
- /// }
- ///
- /// // The optimizer may be able to elide this copy, so previous code writes
- /// // to heap directly.
- /// let big_box = Box::write(big_box, array);
- ///
- /// for (i, x) in big_box.iter().enumerate() {
- /// assert_eq!(*x, i);
- /// }
- /// ```
- #[inline(always)]
- pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
- unsafe {
- (*boxed).write(value);
- boxed.assume_init()
- }
- }
-}
-
-impl<T, A: Allocator> Box<[mem::MaybeUninit<T>], A> {
- /// Converts to `Box<[T], A>`.
- ///
- /// # Safety
- ///
- /// As with [`MaybeUninit::assume_init`],
- /// it is up to the caller to guarantee that the values
- /// really are in an initialized state.
- /// Calling this when the content is not yet fully initialized
- /// causes immediate undefined behavior.
- ///
- /// [`MaybeUninit::assume_init`]: mem::MaybeUninit::assume_init
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(new_uninit)]
- ///
- /// let mut values = Box::<[u32]>::new_uninit_slice(3);
- ///
- /// let values = unsafe {
- /// // Deferred initialization:
- /// values[0].as_mut_ptr().write(1);
- /// values[1].as_mut_ptr().write(2);
- /// values[2].as_mut_ptr().write(3);
- ///
- /// values.assume_init()
- /// };
- ///
- /// assert_eq!(*values, [1, 2, 3])
- /// ```
- #[inline(always)]
- pub unsafe fn assume_init(self) -> Box<[T], A> {
- let (raw, alloc) = Self::into_raw_with_allocator(self);
- unsafe { Box::<[T], A>::from_raw_in(raw as *mut [T], alloc) }
- }
-}
-
-impl<T: ?Sized> Box<T> {
- /// Constructs a box from a raw pointer.
- ///
- /// After calling this function, the raw pointer is owned by the
- /// resulting `Box`. Specifically, the `Box` destructor will call
- /// the destructor of `T` and free the allocated memory. For this
- /// to be safe, the memory must have been allocated in accordance
- /// with the [memory layout] used by `Box` .
- ///
- /// # Safety
- ///
- /// This function is unsafe because improper use may lead to
- /// memory problems. For example, a double-free may occur if the
- /// function is called twice on the same raw pointer.
- ///
- /// The safety conditions are described in the [memory layout] section.
- ///
- /// # Examples
- ///
- /// Recreate a `Box` which was previously converted to a raw pointer
- /// using [`Box::into_raw`]:
- /// ```
- /// let x = Box::new(5);
- /// let ptr = Box::into_raw(x);
- /// let x = unsafe { Box::from_raw(ptr) };
- /// ```
- /// Manually create a `Box` from scratch by using the global allocator:
- /// ```
- /// use std::alloc::{alloc, Layout};
- ///
- /// unsafe {
- /// let ptr = alloc(Layout::new::<i32>()) as *mut i32;
- /// // In general .write is required to avoid attempting to destruct
- /// // the (uninitialized) previous contents of `ptr`, though for this
- /// // simple example `*ptr = 5` would have worked as well.
- /// ptr.write(5);
- /// let x = Box::from_raw(ptr);
- /// }
- /// ```
- ///
- /// [memory layout]: self#memory-layout
- /// [`Layout`]: crate::Layout
- #[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `Box`"]
- #[inline(always)]
- pub unsafe fn from_raw(raw: *mut T) -> Self {
- unsafe { Self::from_raw_in(raw, Global) }
- }
-}
-
-impl<T: ?Sized, A: Allocator> Box<T, A> {
- /// Constructs a box from a raw pointer in the given allocator.
- ///
- /// After calling this function, the raw pointer is owned by the
- /// resulting `Box`. Specifically, the `Box` destructor will call
- /// the destructor of `T` and free the allocated memory. For this
- /// to be safe, the memory must have been allocated in accordance
- /// with the [memory layout] used by `Box` .
- ///
- /// # Safety
- ///
- /// This function is unsafe because improper use may lead to
- /// memory problems. For example, a double-free may occur if the
- /// function is called twice on the same raw pointer.
- ///
- ///
- /// # Examples
- ///
- /// Recreate a `Box` which was previously converted to a raw pointer
- /// using [`Box::into_raw_with_allocator`]:
- /// ```
- /// use std::alloc::System;
- /// # use allocator_api2::boxed::Box;
- ///
- /// let x = Box::new_in(5, System);
- /// let (ptr, alloc) = Box::into_raw_with_allocator(x);
- /// let x = unsafe { Box::from_raw_in(ptr, alloc) };
- /// ```
- /// Manually create a `Box` from scratch by using the system allocator:
- /// ```
- /// use allocator_api2::alloc::{Allocator, Layout, System};
- /// # use allocator_api2::boxed::Box;
- ///
- /// unsafe {
- /// let ptr = System.allocate(Layout::new::<i32>())?.as_ptr().cast::<i32>();
- /// // In general .write is required to avoid attempting to destruct
- /// // the (uninitialized) previous contents of `ptr`, though for this
- /// // simple example `*ptr = 5` would have worked as well.
- /// ptr.write(5);
- /// let x = Box::from_raw_in(ptr, System);
- /// }
- /// # Ok::<(), allocator_api2::alloc::AllocError>(())
- /// ```
- ///
- /// [memory layout]: self#memory-layout
- /// [`Layout`]: crate::Layout
- #[inline(always)]
- pub const unsafe fn from_raw_in(raw: *mut T, alloc: A) -> Self {
- Box(unsafe { Unique::new_unchecked(raw) }, alloc)
- }
-
- /// Consumes the `Box`, returning a wrapped raw pointer.
- ///
- /// The pointer will be properly aligned and non-null.
- ///
- /// After calling this function, the caller is responsible for the
- /// memory previously managed by the `Box`. In particular, the
- /// caller should properly destroy `T` and release the memory, taking
- /// into account the [memory layout] used by `Box`. The easiest way to
- /// do this is to convert the raw pointer back into a `Box` with the
- /// [`Box::from_raw`] function, allowing the `Box` destructor to perform
- /// the cleanup.
- ///
- /// Note: this is an associated function, which means that you have
- /// to call it as `Box::into_raw(b)` instead of `b.into_raw()`. This
- /// is so that there is no conflict with a method on the inner type.
- ///
- /// # Examples
- /// Converting the raw pointer back into a `Box` with [`Box::from_raw`]
- /// for automatic cleanup:
- /// ```
- /// let x = Box::new(String::from("Hello"));
- /// let ptr = Box::into_raw(x);
- /// let x = unsafe { Box::from_raw(ptr) };
- /// ```
- /// Manual cleanup by explicitly running the destructor and deallocating
- /// the memory:
- /// ```
- /// use std::alloc::{dealloc, Layout};
- /// use std::ptr;
- ///
- /// let x = Box::new(String::from("Hello"));
- /// let p = Box::into_raw(x);
- /// unsafe {
- /// ptr::drop_in_place(p);
- /// dealloc(p as *mut u8, Layout::new::<String>());
- /// }
- /// ```
- ///
- /// [memory layout]: self#memory-layout
- #[inline(always)]
- pub fn into_raw(b: Self) -> *mut T {
- Self::into_raw_with_allocator(b).0
- }
-
- /// Consumes the `Box`, returning a wrapped raw pointer and the allocator.
- ///
- /// The pointer will be properly aligned and non-null.
- ///
- /// After calling this function, the caller is responsible for the
- /// memory previously managed by the `Box`. In particular, the
- /// caller should properly destroy `T` and release the memory, taking
- /// into account the [memory layout] used by `Box`. The easiest way to
- /// do this is to convert the raw pointer back into a `Box` with the
- /// [`Box::from_raw_in`] function, allowing the `Box` destructor to perform
- /// the cleanup.
- ///
- /// Note: this is an associated function, which means that you have
- /// to call it as `Box::into_raw_with_allocator(b)` instead of `b.into_raw_with_allocator()`. This
- /// is so that there is no conflict with a method on the inner type.
- ///
- /// # Examples
- /// Converting the raw pointer back into a `Box` with [`Box::from_raw_in`]
- /// for automatic cleanup:
- /// ```
- /// #![feature(allocator_api)]
- ///
- /// use std::alloc::System;
- ///
- /// let x = Box::new_in(String::from("Hello"), System);
- /// let (ptr, alloc) = Box::into_raw_with_allocator(x);
- /// let x = unsafe { Box::from_raw_in(ptr, alloc) };
- /// ```
- /// Manual cleanup by explicitly running the destructor and deallocating
- /// the memory:
- /// ```
- /// #![feature(allocator_api)]
- ///
- /// use std::alloc::{Allocator, Layout, System};
- /// use std::ptr::{self, NonNull};
- ///
- /// let x = Box::new_in(String::from("Hello"), System);
- /// let (ptr, alloc) = Box::into_raw_with_allocator(x);
- /// unsafe {
- /// ptr::drop_in_place(ptr);
- /// let non_null = NonNull::new_unchecked(ptr);
- /// alloc.deallocate(non_null.cast(), Layout::new::<String>());
- /// }
- /// ```
- ///
- /// [memory layout]: self#memory-layout
- #[inline(always)]
- pub fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
- let (leaked, alloc) = Box::into_non_null(b);
- (leaked.as_ptr(), alloc)
- }
-
- #[inline(always)]
- pub fn into_non_null(b: Self) -> (NonNull<T>, A) {
- // Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
- // raw pointer for the type system. Turning it directly into a raw pointer would not be
- // recognized as "releasing" the unique pointer to permit aliased raw accesses,
- // so all raw pointer methods have to go through `Box::leak`. Turning *that* to a raw pointer
- // behaves correctly.
- let alloc = unsafe { ptr::read(&b.1) };
- (NonNull::from(Box::leak(b)), alloc)
- }
-
- /// Returns a reference to the underlying allocator.
- ///
- /// Note: this is an associated function, which means that you have
- /// to call it as `Box::allocator(&b)` instead of `b.allocator()`. This
- /// is so that there is no conflict with a method on the inner type.
- #[inline(always)]
- pub const fn allocator(b: &Self) -> &A {
- &b.1
- }
-
- /// Consumes and leaks the `Box`, returning a mutable reference,
- /// `&'a mut T`. Note that the type `T` must outlive the chosen lifetime
- /// `'a`. If the type has only static references, or none at all, then this
- /// may be chosen to be `'static`.
- ///
- /// This function is mainly useful for data that lives for the remainder of
- /// the program's life. Dropping the returned reference will cause a memory
- /// leak. If this is not acceptable, the reference should first be wrapped
- /// with the [`Box::from_raw`] function producing a `Box`. This `Box` can
- /// then be dropped which will properly destroy `T` and release the
- /// allocated memory.
- ///
- /// Note: this is an associated function, which means that you have
- /// to call it as `Box::leak(b)` instead of `b.leak()`. This
- /// is so that there is no conflict with a method on the inner type.
- ///
- /// # Examples
- ///
- /// Simple usage:
- ///
- /// ```
- /// let x = Box::new(41);
- /// let static_ref: &'static mut usize = Box::leak(x);
- /// *static_ref += 1;
- /// assert_eq!(*static_ref, 42);
- /// ```
- ///
- /// Unsized data:
- ///
- /// ```
- /// let x = vec![1, 2, 3].into_boxed_slice();
- /// let static_ref = Box::leak(x);
- /// static_ref[0] = 4;
- /// assert_eq!(*static_ref, [4, 2, 3]);
- /// ```
- #[inline(always)]
- pub fn leak<'a>(b: Self) -> &'a mut T
- where
- A: 'a,
- {
- unsafe { &mut *mem::ManuallyDrop::new(b).0.as_ptr() }
- }
-
- /// Converts a `Box<T>` into a `Pin<Box<T>>`. If `T` does not implement [`Unpin`], then
- /// `*boxed` will be pinned in memory and unable to be moved.
- ///
- /// This conversion does not allocate on the heap and happens in place.
- ///
- /// This is also available via [`From`].
- ///
- /// Constructing and pinning a `Box` with <code>Box::into_pin([Box::new]\(x))</code>
- /// can also be written more concisely using <code>[Box::pin]\(x)</code>.
- /// This `into_pin` method is useful if you already have a `Box<T>`, or you are
- /// constructing a (pinned) `Box` in a different way than with [`Box::new`].
- ///
- /// # Notes
- ///
- /// It's not recommended that crates add an impl like `From<Box<T>> for Pin<T>`,
- /// as it'll introduce an ambiguity when calling `Pin::from`.
- /// A demonstration of such a poor impl is shown below.
- ///
- /// ```compile_fail
- /// # use std::pin::Pin;
- /// struct Foo; // A type defined in this crate.
- /// impl From<Box<()>> for Pin<Foo> {
- /// fn from(_: Box<()>) -> Pin<Foo> {
- /// Pin::new(Foo)
- /// }
- /// }
- ///
- /// let foo = Box::new(());
- /// let bar = Pin::from(foo);
- /// ```
- #[inline(always)]
- pub fn into_pin(boxed: Self) -> Pin<Self>
- where
- A: 'static,
- {
- // It's not possible to move or replace the insides of a `Pin<Box<T>>`
- // when `T: !Unpin`, so it's safe to pin it directly without any
- // additional requirements.
- unsafe { Pin::new_unchecked(boxed) }
- }
-}
-
-impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
- #[inline(always)]
- fn drop(&mut self) {
- let layout = Layout::for_value::<T>(&**self);
- unsafe {
- ptr::drop_in_place(self.0.as_mut());
- self.1.deallocate(self.0.as_non_null_ptr().cast(), layout);
- }
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<T: Default> Default for Box<T> {
- /// Creates a `Box<T>`, with the `Default` value for T.
- #[inline(always)]
- fn default() -> Self {
- Box::new(T::default())
- }
-}
-
-impl<T, A: Allocator + Default> Default for Box<[T], A> {
- #[inline(always)]
- fn default() -> Self {
- let ptr: NonNull<[T]> = NonNull::<[T; 0]>::dangling();
- Box(unsafe { Unique::new_unchecked(ptr.as_ptr()) }, A::default())
- }
-}
-
-impl<A: Allocator + Default> Default for Box<str, A> {
- #[inline(always)]
- fn default() -> Self {
- // SAFETY: This is the same as `Unique::cast<U>` but with an unsized `U = str`.
- let ptr: Unique<str> = unsafe {
- let bytes: NonNull<[u8]> = NonNull::<[u8; 0]>::dangling();
- Unique::new_unchecked(bytes.as_ptr() as *mut str)
- };
- Box(ptr, A::default())
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<T: Clone, A: Allocator + Clone> Clone for Box<T, A> {
- /// Returns a new box with a `clone()` of this box's contents.
- ///
- /// # Examples
- ///
- /// ```
- /// let x = Box::new(5);
- /// let y = x.clone();
- ///
- /// // The value is the same
- /// assert_eq!(x, y);
- ///
- /// // But they are unique objects
- /// assert_ne!(&*x as *const i32, &*y as *const i32);
- /// ```
- #[inline(always)]
- fn clone(&self) -> Self {
- // Pre-allocate memory to allow writing the cloned value directly.
- let mut boxed = Self::new_uninit_in(self.1.clone());
- unsafe {
- boxed.write((**self).clone());
- boxed.assume_init()
- }
- }
-
- /// Copies `source`'s contents into `self` without creating a new allocation.
- ///
- /// # Examples
- ///
- /// ```
- /// let x = Box::new(5);
- /// let mut y = Box::new(10);
- /// let yp: *const i32 = &*y;
- ///
- /// y.clone_from(&x);
- ///
- /// // The value is the same
- /// assert_eq!(x, y);
- ///
- /// // And no allocation occurred
- /// assert_eq!(yp, &*y);
- /// ```
- #[inline(always)]
- fn clone_from(&mut self, source: &Self) {
- (**self).clone_from(&(**source));
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl Clone for Box<str> {
- #[inline(always)]
- fn clone(&self) -> Self {
- // this makes a copy of the data
- let buf: Box<[u8]> = self.as_bytes().into();
- unsafe { Box::from_raw(Box::into_raw(buf) as *mut str) }
- }
-}
-
-impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for Box<T, A> {
- #[inline(always)]
- fn eq(&self, other: &Self) -> bool {
- PartialEq::eq(&**self, &**other)
- }
- #[inline(always)]
- fn ne(&self, other: &Self) -> bool {
- PartialEq::ne(&**self, &**other)
- }
-}
-
-impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Box<T, A> {
- #[inline(always)]
- fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
- PartialOrd::partial_cmp(&**self, &**other)
- }
- #[inline(always)]
- fn lt(&self, other: &Self) -> bool {
- PartialOrd::lt(&**self, &**other)
- }
- #[inline(always)]
- fn le(&self, other: &Self) -> bool {
- PartialOrd::le(&**self, &**other)
- }
- #[inline(always)]
- fn ge(&self, other: &Self) -> bool {
- PartialOrd::ge(&**self, &**other)
- }
- #[inline(always)]
- fn gt(&self, other: &Self) -> bool {
- PartialOrd::gt(&**self, &**other)
- }
-}
-
-impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
- #[inline(always)]
- fn cmp(&self, other: &Self) -> Ordering {
- Ord::cmp(&**self, &**other)
- }
-}
-
-impl<T: ?Sized + Eq, A: Allocator> Eq for Box<T, A> {}
-
-impl<T: ?Sized + Hash, A: Allocator> Hash for Box<T, A> {
- #[inline(always)]
- fn hash<H: Hasher>(&self, state: &mut H) {
- (**self).hash(state);
- }
-}
-
-impl<T: ?Sized + Hasher, A: Allocator> Hasher for Box<T, A> {
- #[inline(always)]
- fn finish(&self) -> u64 {
- (**self).finish()
- }
- #[inline(always)]
- fn write(&mut self, bytes: &[u8]) {
- (**self).write(bytes)
- }
- #[inline(always)]
- fn write_u8(&mut self, i: u8) {
- (**self).write_u8(i)
- }
- #[inline(always)]
- fn write_u16(&mut self, i: u16) {
- (**self).write_u16(i)
- }
- #[inline(always)]
- fn write_u32(&mut self, i: u32) {
- (**self).write_u32(i)
- }
- #[inline(always)]
- fn write_u64(&mut self, i: u64) {
- (**self).write_u64(i)
- }
- #[inline(always)]
- fn write_u128(&mut self, i: u128) {
- (**self).write_u128(i)
- }
- #[inline(always)]
- fn write_usize(&mut self, i: usize) {
- (**self).write_usize(i)
- }
- #[inline(always)]
- fn write_i8(&mut self, i: i8) {
- (**self).write_i8(i)
- }
- #[inline(always)]
- fn write_i16(&mut self, i: i16) {
- (**self).write_i16(i)
- }
- #[inline(always)]
- fn write_i32(&mut self, i: i32) {
- (**self).write_i32(i)
- }
- #[inline(always)]
- fn write_i64(&mut self, i: i64) {
- (**self).write_i64(i)
- }
- #[inline(always)]
- fn write_i128(&mut self, i: i128) {
- (**self).write_i128(i)
- }
- #[inline(always)]
- fn write_isize(&mut self, i: isize) {
- (**self).write_isize(i)
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<T> From<T> for Box<T> {
- /// Converts a `T` into a `Box<T>`
- ///
- /// The conversion allocates on the heap and moves `t`
- /// from the stack into it.
- ///
- /// # Examples
- ///
- /// ```rust
- /// let x = 5;
- /// let boxed = Box::new(5);
- ///
- /// assert_eq!(Box::from(x), boxed);
- /// ```
- #[inline(always)]
- fn from(t: T) -> Self {
- Box::new(t)
- }
-}
-
-impl<T: ?Sized, A: Allocator> From<Box<T, A>> for Pin<Box<T, A>>
-where
- A: 'static,
-{
- /// Converts a `Box<T>` into a `Pin<Box<T>>`. If `T` does not implement [`Unpin`], then
- /// `*boxed` will be pinned in memory and unable to be moved.
- ///
- /// This conversion does not allocate on the heap and happens in place.
- ///
- /// This is also available via [`Box::into_pin`].
- ///
- /// Constructing and pinning a `Box` with <code><Pin<Box\<T>>>::from([Box::new]\(x))</code>
- /// can also be written more concisely using <code>[Box::pin]\(x)</code>.
- /// This `From` implementation is useful if you already have a `Box<T>`, or you are
- /// constructing a (pinned) `Box` in a different way than with [`Box::new`].
- #[inline(always)]
- fn from(boxed: Box<T, A>) -> Self {
- Box::into_pin(boxed)
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<T: Copy, A: Allocator + Default> From<&[T]> for Box<[T], A> {
- /// Converts a `&[T]` into a `Box<[T]>`
- ///
- /// This conversion allocates on the heap
- /// and performs a copy of `slice` and its contents.
- ///
- /// # Examples
- /// ```rust
- /// // create a &[u8] which will be used to create a Box<[u8]>
- /// let slice: &[u8] = &[104, 101, 108, 108, 111];
- /// let boxed_slice: Box<[u8]> = Box::from(slice);
- ///
- /// println!("{boxed_slice:?}");
- /// ```
- #[inline(always)]
- fn from(slice: &[T]) -> Box<[T], A> {
- let len = slice.len();
- let buf = RawVec::with_capacity_in(len, A::default());
- unsafe {
- ptr::copy_nonoverlapping(slice.as_ptr(), buf.ptr(), len);
- buf.into_box(slice.len()).assume_init()
- }
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<A: Allocator + Default> From<&str> for Box<str, A> {
- /// Converts a `&str` into a `Box<str>`
- ///
- /// This conversion allocates on the heap
- /// and performs a copy of `s`.
- ///
- /// # Examples
- ///
- /// ```rust
- /// let boxed: Box<str> = Box::from("hello");
- /// println!("{boxed}");
- /// ```
- #[inline(always)]
- fn from(s: &str) -> Box<str, A> {
- let (raw, alloc) = Box::into_raw_with_allocator(Box::<[u8], A>::from(s.as_bytes()));
- unsafe { Box::from_raw_in(raw as *mut str, alloc) }
- }
-}
-
-impl<A: Allocator> From<Box<str, A>> for Box<[u8], A> {
- /// Converts a `Box<str>` into a `Box<[u8]>`
- ///
- /// This conversion does not allocate on the heap and happens in place.
- ///
- /// # Examples
- /// ```rust
- /// // create a Box<str> which will be used to create a Box<[u8]>
- /// let boxed: Box<str> = Box::from("hello");
- /// let boxed_str: Box<[u8]> = Box::from(boxed);
- ///
- /// // create a &[u8] which will be used to create a Box<[u8]>
- /// let slice: &[u8] = &[104, 101, 108, 108, 111];
- /// let boxed_slice = Box::from(slice);
- ///
- /// assert_eq!(boxed_slice, boxed_str);
- /// ```
- #[inline(always)]
- fn from(s: Box<str, A>) -> Self {
- let (raw, alloc) = Box::into_raw_with_allocator(s);
- unsafe { Box::from_raw_in(raw as *mut [u8], alloc) }
- }
-}
-
-impl<T, A: Allocator, const N: usize> Box<[T; N], A> {
- #[inline(always)]
- pub fn slice(b: Self) -> Box<[T], A> {
- let (ptr, alloc) = Box::into_raw_with_allocator(b);
- unsafe { Box::from_raw_in(ptr, alloc) }
- }
-
- pub fn into_vec(self) -> Vec<T, A>
- where
- A: Allocator,
- {
- unsafe {
- let (b, alloc) = Box::into_raw_with_allocator(self);
- Vec::from_raw_parts_in(b as *mut T, N, N, alloc)
- }
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<T, const N: usize> From<[T; N]> for Box<[T]> {
- /// Converts a `[T; N]` into a `Box<[T]>`
- ///
- /// This conversion moves the array to newly heap-allocated memory.
- ///
- /// # Examples
- ///
- /// ```rust
- /// let boxed: Box<[u8]> = Box::from([4, 2]);
- /// println!("{boxed:?}");
- /// ```
- #[inline(always)]
- fn from(array: [T; N]) -> Box<[T]> {
- Box::slice(Box::new(array))
- }
-}
-
-impl<T, A: Allocator, const N: usize> TryFrom<Box<[T], A>> for Box<[T; N], A> {
- type Error = Box<[T], A>;
-
- /// Attempts to convert a `Box<[T]>` into a `Box<[T; N]>`.
- ///
- /// The conversion occurs in-place and does not require a
- /// new memory allocation.
- ///
- /// # Errors
- ///
- /// Returns the old `Box<[T]>` in the `Err` variant if
- /// `boxed_slice.len()` does not equal `N`.
- #[inline(always)]
- fn try_from(boxed_slice: Box<[T], A>) -> Result<Self, Self::Error> {
- if boxed_slice.len() == N {
- let (ptr, alloc) = Box::into_raw_with_allocator(boxed_slice);
- Ok(unsafe { Box::from_raw_in(ptr as *mut [T; N], alloc) })
- } else {
- Err(boxed_slice)
- }
- }
-}
-
-impl<A: Allocator> Box<dyn Any, A> {
- /// Attempt to downcast the box to a concrete type.
- ///
- /// # Examples
- ///
- /// ```
- /// use std::any::Any;
- ///
- /// fn print_if_string(value: Box<dyn Any>) {
- /// if let Ok(string) = value.downcast::<String>() {
- /// println!("String ({}): {}", string.len(), string);
- /// }
- /// }
- ///
- /// let my_string = "Hello World".to_string();
- /// print_if_string(Box::new(my_string));
- /// print_if_string(Box::new(0i8));
- /// ```
- #[inline(always)]
- pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> {
- if self.is::<T>() {
- unsafe { Ok(self.downcast_unchecked::<T>()) }
- } else {
- Err(self)
- }
- }
-
- /// Downcasts the box to a concrete type.
- ///
- /// For a safe alternative see [`downcast`].
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(downcast_unchecked)]
- ///
- /// use std::any::Any;
- ///
- /// let x: Box<dyn Any> = Box::new(1_usize);
- ///
- /// unsafe {
- /// assert_eq!(*x.downcast_unchecked::<usize>(), 1);
- /// }
- /// ```
- ///
- /// # Safety
- ///
- /// The contained value must be of type `T`. Calling this method
- /// with the incorrect type is *undefined behavior*.
- ///
- /// [`downcast`]: Self::downcast
- #[inline(always)]
- pub unsafe fn downcast_unchecked<T: Any>(self) -> Box<T, A> {
- debug_assert!(self.is::<T>());
- unsafe {
- let (raw, alloc): (*mut dyn Any, _) = Box::into_raw_with_allocator(self);
- Box::from_raw_in(raw as *mut T, alloc)
- }
- }
-}
-
-impl<A: Allocator> Box<dyn Any + Send, A> {
- /// Attempt to downcast the box to a concrete type.
- ///
- /// # Examples
- ///
- /// ```
- /// use std::any::Any;
- ///
- /// fn print_if_string(value: Box<dyn Any + Send>) {
- /// if let Ok(string) = value.downcast::<String>() {
- /// println!("String ({}): {}", string.len(), string);
- /// }
- /// }
- ///
- /// let my_string = "Hello World".to_string();
- /// print_if_string(Box::new(my_string));
- /// print_if_string(Box::new(0i8));
- /// ```
- #[inline(always)]
- pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> {
- if self.is::<T>() {
- unsafe { Ok(self.downcast_unchecked::<T>()) }
- } else {
- Err(self)
- }
- }
-
- /// Downcasts the box to a concrete type.
- ///
- /// For a safe alternative see [`downcast`].
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(downcast_unchecked)]
- ///
- /// use std::any::Any;
- ///
- /// let x: Box<dyn Any + Send> = Box::new(1_usize);
- ///
- /// unsafe {
- /// assert_eq!(*x.downcast_unchecked::<usize>(), 1);
- /// }
- /// ```
- ///
- /// # Safety
- ///
- /// The contained value must be of type `T`. Calling this method
- /// with the incorrect type is *undefined behavior*.
- ///
- /// [`downcast`]: Self::downcast
- #[inline(always)]
- pub unsafe fn downcast_unchecked<T: Any>(self) -> Box<T, A> {
- debug_assert!(self.is::<T>());
- unsafe {
- let (raw, alloc): (*mut (dyn Any + Send), _) = Box::into_raw_with_allocator(self);
- Box::from_raw_in(raw as *mut T, alloc)
- }
- }
-}
-
-impl<A: Allocator> Box<dyn Any + Send + Sync, A> {
- /// Attempt to downcast the box to a concrete type.
- ///
- /// # Examples
- ///
- /// ```
- /// use std::any::Any;
- ///
- /// fn print_if_string(value: Box<dyn Any + Send + Sync>) {
- /// if let Ok(string) = value.downcast::<String>() {
- /// println!("String ({}): {}", string.len(), string);
- /// }
- /// }
- ///
- /// let my_string = "Hello World".to_string();
- /// print_if_string(Box::new(my_string));
- /// print_if_string(Box::new(0i8));
- /// ```
- #[inline(always)]
- pub fn downcast<T: Any>(self) -> Result<Box<T, A>, Self> {
- if self.is::<T>() {
- unsafe { Ok(self.downcast_unchecked::<T>()) }
- } else {
- Err(self)
- }
- }
-
- /// Downcasts the box to a concrete type.
- ///
- /// For a safe alternative see [`downcast`].
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(downcast_unchecked)]
- ///
- /// use std::any::Any;
- ///
- /// let x: Box<dyn Any + Send + Sync> = Box::new(1_usize);
- ///
- /// unsafe {
- /// assert_eq!(*x.downcast_unchecked::<usize>(), 1);
- /// }
- /// ```
- ///
- /// # Safety
- ///
- /// The contained value must be of type `T`. Calling this method
- /// with the incorrect type is *undefined behavior*.
- ///
- /// [`downcast`]: Self::downcast
- #[inline(always)]
- pub unsafe fn downcast_unchecked<T: Any>(self) -> Box<T, A> {
- debug_assert!(self.is::<T>());
- unsafe {
- let (raw, alloc): (*mut (dyn Any + Send + Sync), _) =
- Box::into_raw_with_allocator(self);
- Box::from_raw_in(raw as *mut T, alloc)
- }
- }
-}
-
-impl<T: fmt::Display + ?Sized, A: Allocator> fmt::Display for Box<T, A> {
- #[inline(always)]
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- fmt::Display::fmt(&**self, f)
- }
-}
-
-impl<T: fmt::Debug + ?Sized, A: Allocator> fmt::Debug for Box<T, A> {
- #[inline(always)]
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- fmt::Debug::fmt(&**self, f)
- }
-}
-
-impl<T: ?Sized, A: Allocator> fmt::Pointer for Box<T, A> {
- #[inline(always)]
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- // It's not possible to extract the inner Uniq directly from the Box,
- // instead we cast it to a *const which aliases the Unique
- let ptr: *const T = &**self;
- fmt::Pointer::fmt(&ptr, f)
- }
-}
-
-impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
- type Target = T;
-
- #[inline(always)]
- fn deref(&self) -> &T {
- unsafe { self.0.as_ref() }
- }
-}
-
-impl<T: ?Sized, A: Allocator> DerefMut for Box<T, A> {
- #[inline(always)]
- fn deref_mut(&mut self) -> &mut T {
- unsafe { self.0.as_mut() }
- }
-}
-
-impl<I: Iterator + ?Sized, A: Allocator> Iterator for Box<I, A> {
- type Item = I::Item;
-
- #[inline(always)]
- fn next(&mut self) -> Option<I::Item> {
- (**self).next()
- }
-
- #[inline(always)]
- fn size_hint(&self) -> (usize, Option<usize>) {
- (**self).size_hint()
- }
-
- #[inline(always)]
- fn nth(&mut self, n: usize) -> Option<I::Item> {
- (**self).nth(n)
- }
-
- #[inline(always)]
- fn last(self) -> Option<I::Item> {
- BoxIter::last(self)
- }
-}
-
-trait BoxIter {
- type Item;
- fn last(self) -> Option<Self::Item>;
-}
-
-impl<I: Iterator + ?Sized, A: Allocator> BoxIter for Box<I, A> {
- type Item = I::Item;
-
- #[inline(always)]
- fn last(self) -> Option<I::Item> {
- #[inline(always)]
- fn some<T>(_: Option<T>, x: T) -> Option<T> {
- Some(x)
- }
-
- self.fold(None, some)
- }
-}
-
-impl<I: DoubleEndedIterator + ?Sized, A: Allocator> DoubleEndedIterator for Box<I, A> {
- #[inline(always)]
- fn next_back(&mut self) -> Option<I::Item> {
- (**self).next_back()
- }
- #[inline(always)]
- fn nth_back(&mut self, n: usize) -> Option<I::Item> {
- (**self).nth_back(n)
- }
-}
-
-impl<I: ExactSizeIterator + ?Sized, A: Allocator> ExactSizeIterator for Box<I, A> {
- #[inline(always)]
- fn len(&self) -> usize {
- (**self).len()
- }
-}
-
-impl<I: FusedIterator + ?Sized, A: Allocator> FusedIterator for Box<I, A> {}
-
-#[cfg(not(no_global_oom_handling))]
-impl<I> FromIterator<I> for Box<[I]> {
- #[inline(always)]
- fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self {
- iter.into_iter().collect::<Vec<_>>().into_boxed_slice()
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-impl<T: Clone, A: Allocator + Clone> Clone for Box<[T], A> {
- #[inline(always)]
- fn clone(&self) -> Self {
- let alloc = Box::allocator(self).clone();
- let mut vec = Vec::with_capacity_in(self.len(), alloc);
- vec.extend_from_slice(self);
- vec.into_boxed_slice()
- }
-
- #[inline(always)]
- fn clone_from(&mut self, other: &Self) {
- if self.len() == other.len() {
- self.clone_from_slice(other);
- } else {
- *self = other.clone();
- }
- }
-}
-
-impl<T: ?Sized, A: Allocator> borrow::Borrow<T> for Box<T, A> {
- #[inline(always)]
- fn borrow(&self) -> &T {
- self
- }
-}
-
-impl<T: ?Sized, A: Allocator> borrow::BorrowMut<T> for Box<T, A> {
- #[inline(always)]
- fn borrow_mut(&mut self) -> &mut T {
- self
- }
-}
-
-impl<T: ?Sized, A: Allocator> AsRef<T> for Box<T, A> {
- #[inline(always)]
- fn as_ref(&self) -> &T {
- self
- }
-}
-
-impl<T: ?Sized, A: Allocator> AsMut<T> for Box<T, A> {
- #[inline(always)]
- fn as_mut(&mut self) -> &mut T {
- self
- }
-}
-
-/* Nota bene
- *
- * We could have chosen not to add this impl, and instead have written a
- * function of Pin<Box<T>> to Pin<T>. Such a function would not be sound,
- * because Box<T> implements Unpin even when T does not, as a result of
- * this impl.
- *
- * We chose this API instead of the alternative for a few reasons:
- * - Logically, it is helpful to understand pinning in regard to the
- * memory region being pointed to. For this reason none of the
- * standard library pointer types support projecting through a pin
- * (Box<T> is the only pointer type in std for which this would be
- * safe.)
- * - It is in practice very useful to have Box<T> be unconditionally
- * Unpin because of trait objects, for which the structural auto
- * trait functionality does not apply (e.g., Box<dyn Foo> would
- * otherwise not be Unpin).
- *
- * Another type with the same semantics as Box but only a conditional
- * implementation of `Unpin` (where `T: Unpin`) would be valid/safe, and
- * could have a method to project a Pin<T> from it.
- */
-impl<T: ?Sized, A: Allocator> Unpin for Box<T, A> where A: 'static {}
-
-impl<F: ?Sized + Future + Unpin, A: Allocator> Future for Box<F, A>
-where
- A: 'static,
-{
- type Output = F::Output;
-
- #[inline(always)]
- fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
- F::poll(Pin::new(&mut *self), cx)
- }
-}
-
-#[cfg(feature = "std")]
-mod error {
- use std::error::Error;
-
- use super::Box;
-
- #[cfg(not(no_global_oom_handling))]
- impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
- /// Converts a type of [`Error`] into a box of dyn [`Error`].
- ///
- /// # Examples
- ///
- /// ```
- /// use std::error::Error;
- /// use std::fmt;
- /// use std::mem;
- ///
- /// #[derive(Debug)]
- /// struct AnError;
- ///
- /// impl fmt::Display for AnError {
- /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- /// write!(f, "An error")
- /// }
- /// }
- ///
- /// impl Error for AnError {}
- ///
- /// let an_error = AnError;
- /// assert!(0 == mem::size_of_val(&an_error));
- /// let a_boxed_error = Box::<dyn Error>::from(an_error);
- /// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
- /// ```
- #[inline(always)]
- fn from(err: E) -> Box<dyn Error + 'a> {
- unsafe { Box::from_raw(Box::leak(Box::new(err))) }
- }
- }
-
- #[cfg(not(no_global_oom_handling))]
- impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync + 'a> {
- /// Converts a type of [`Error`] + [`Send`] + [`Sync`] into a box of
- /// dyn [`Error`] + [`Send`] + [`Sync`].
- ///
- /// # Examples
- ///
- /// ```
- /// use std::error::Error;
- /// use std::fmt;
- /// use std::mem;
- ///
- /// #[derive(Debug)]
- /// struct AnError;
- ///
- /// impl fmt::Display for AnError {
- /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- /// write!(f, "An error")
- /// }
- /// }
- ///
- /// impl Error for AnError {}
- ///
- /// unsafe impl Send for AnError {}
- ///
- /// unsafe impl Sync for AnError {}
- ///
- /// let an_error = AnError;
- /// assert!(0 == mem::size_of_val(&an_error));
- /// let a_boxed_error = Box::<dyn Error + Send + Sync>::from(an_error);
- /// assert!(
- /// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
- /// ```
- #[inline(always)]
- fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> {
- unsafe { Box::from_raw(Box::leak(Box::new(err))) }
- }
- }
-
- impl<T: Error> Error for Box<T> {
- #[inline(always)]
- fn source(&self) -> Option<&(dyn Error + 'static)> {
- Error::source(&**self)
- }
- }
-}
-
-#[cfg(feature = "std")]
-impl<R: std::io::Read + ?Sized, A: Allocator> std::io::Read for Box<R, A> {
- #[inline]
- fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
- (**self).read(buf)
- }
-
- #[inline]
- fn read_to_end(&mut self, buf: &mut std::vec::Vec<u8>) -> std::io::Result<usize> {
- (**self).read_to_end(buf)
- }
-
- #[inline]
- fn read_to_string(&mut self, buf: &mut String) -> std::io::Result<usize> {
- (**self).read_to_string(buf)
- }
-
- #[inline]
- fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> {
- (**self).read_exact(buf)
- }
-}
-
-#[cfg(feature = "std")]
-impl<W: std::io::Write + ?Sized, A: Allocator> std::io::Write for Box<W, A> {
- #[inline]
- fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
- (**self).write(buf)
- }
-
- #[inline]
- fn flush(&mut self) -> std::io::Result<()> {
- (**self).flush()
- }
-
- #[inline]
- fn write_all(&mut self, buf: &[u8]) -> std::io::Result<()> {
- (**self).write_all(buf)
- }
-
- #[inline]
- fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> std::io::Result<()> {
- (**self).write_fmt(fmt)
- }
-}
-
-#[cfg(feature = "std")]
-impl<S: std::io::Seek + ?Sized, A: Allocator> std::io::Seek for Box<S, A> {
- #[inline]
- fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result<u64> {
- (**self).seek(pos)
- }
-
- #[inline]
- fn stream_position(&mut self) -> std::io::Result<u64> {
- (**self).stream_position()
- }
-}
-
-#[cfg(feature = "std")]
-impl<B: std::io::BufRead + ?Sized, A: Allocator> std::io::BufRead for Box<B, A> {
- #[inline]
- fn fill_buf(&mut self) -> std::io::Result<&[u8]> {
- (**self).fill_buf()
- }
-
- #[inline]
- fn consume(&mut self, amt: usize) {
- (**self).consume(amt)
- }
-
- #[inline]
- fn read_until(&mut self, byte: u8, buf: &mut std::vec::Vec<u8>) -> std::io::Result<usize> {
- (**self).read_until(byte, buf)
- }
-
- #[inline]
- fn read_line(&mut self, buf: &mut std::string::String) -> std::io::Result<usize> {
- (**self).read_line(buf)
- }
-}
-
-#[cfg(feature = "alloc")]
-impl<A: Allocator> Extend<Box<str, A>> for alloc_crate::string::String {
- fn extend<I: IntoIterator<Item = Box<str, A>>>(&mut self, iter: I) {
- iter.into_iter().for_each(move |s| self.push_str(&s));
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-#[cfg(feature = "std")]
-impl Clone for Box<std::ffi::CStr> {
- #[inline]
- fn clone(&self) -> Self {
- (**self).into()
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-#[cfg(feature = "std")]
-impl From<&std::ffi::CStr> for Box<std::ffi::CStr> {
- /// Converts a `&CStr` into a `Box<CStr>`,
- /// by copying the contents into a newly allocated [`Box`].
- fn from(s: &std::ffi::CStr) -> Box<std::ffi::CStr> {
- let boxed: Box<[u8]> = Box::from(s.to_bytes_with_nul());
- unsafe { Box::from_raw(Box::into_raw(boxed) as *mut std::ffi::CStr) }
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-#[cfg(feature = "fresh-rust")]
-impl Clone for Box<core::ffi::CStr> {
- #[inline]
- fn clone(&self) -> Self {
- (**self).into()
- }
-}
-
-#[cfg(not(no_global_oom_handling))]
-#[cfg(feature = "fresh-rust")]
-impl From<&core::ffi::CStr> for Box<core::ffi::CStr> {
- /// Converts a `&CStr` into a `Box<CStr>`,
- /// by copying the contents into a newly allocated [`Box`].
- fn from(s: &core::ffi::CStr) -> Box<core::ffi::CStr> {
- let boxed: Box<[u8]> = Box::from(s.to_bytes_with_nul());
- unsafe { Box::from_raw(Box::into_raw(boxed) as *mut core::ffi::CStr) }
- }
-}
-
-#[cfg(feature = "serde")]
-impl<T, A> serde::Serialize for Box<T, A>
-where
- T: serde::Serialize,
- A: Allocator,
-{
- #[inline(always)]
- fn serialize<S: serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
- (**self).serialize(serializer)
- }
-}
-
-#[cfg(feature = "serde")]
-impl<'de, T, A> serde::Deserialize<'de> for Box<T, A>
-where
- T: serde::Deserialize<'de>,
- A: Allocator + Default,
-{
- #[inline(always)]
- fn deserialize<D: serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
- let value = T::deserialize(deserializer)?;
- Ok(Box::new_in(value, A::default()))
- }
-}
diff --git a/external/vendor/allocator-api2/src/stable/macros.rs b/external/vendor/allocator-api2/src/stable/macros.rs
deleted file mode 100644
index f67c5875..00000000
--- a/external/vendor/allocator-api2/src/stable/macros.rs
+++ /dev/null
@@ -1,83 +0,0 @@
-/// Creates a [`Vec`] containing the arguments.
-///
-/// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
-/// There are two forms of this macro:
-///
-/// - Create a [`Vec`] containing a given list of elements:
-///
-/// ```
-/// use allocator_api2::vec;
-/// let v = vec![1, 2, 3];
-/// assert_eq!(v[0], 1);
-/// assert_eq!(v[1], 2);
-/// assert_eq!(v[2], 3);
-/// ```
-///
-///
-/// ```
-/// use allocator_api2::{vec, alloc::Global};
-/// let v = vec![in Global; 1, 2, 3];
-/// assert_eq!(v[0], 1);
-/// assert_eq!(v[1], 2);
-/// assert_eq!(v[2], 3);
-/// ```
-///
-/// - Create a [`Vec`] from a given element and size:
-///
-/// ```
-/// use allocator_api2::vec;
-/// let v = vec![1; 3];
-/// assert_eq!(v, [1, 1, 1]);
-/// ```
-///
-/// ```
-/// use allocator_api2::{vec, alloc::Global};
-/// let v = vec![in Global; 1; 3];
-/// assert_eq!(v, [1, 1, 1]);
-/// ```
-///
-/// Note that unlike array expressions this syntax supports all elements
-/// which implement [`Clone`] and the number of elements doesn't have to be
-/// a constant.
-///
-/// This will use `clone` to duplicate an expression, so one should be careful
-/// using this with types having a nonstandard `Clone` implementation. For
-/// example, `vec![Rc::new(1); 5]` will create a vector of five references
-/// to the same boxed integer value, not five references pointing to independently
-/// boxed integers.
-///
-/// Also, note that `vec![expr; 0]` is allowed, and produces an empty vector.
-/// This will still evaluate `expr`, however, and immediately drop the resulting value, so
-/// be mindful of side effects.
-///
-/// [`Vec`]: crate::vec::Vec
-#[cfg(not(no_global_oom_handling))]
-#[macro_export]
-macro_rules! vec {
- (in $alloc:expr $(;)?) => (
- $crate::vec::Vec::new_in($alloc)
- );
- (in $alloc:expr; $elem:expr; $n:expr) => (
- $crate::vec::from_elem_in($elem, $n, $alloc)
- );
- (in $alloc:expr; $($x:expr),+ $(,)?) => (
- $crate::boxed::Box::<[_]>::into_vec(
- $crate::boxed::Box::slice(
- $crate::boxed::Box::new_in([$($x),+], $alloc)
- )
- )
- );
- () => (
- $crate::vec::Vec::new()
- );
- ($elem:expr; $n:expr) => (
- $crate::vec::from_elem($elem, $n)
- );
- ($($x:expr),+ $(,)?) => (
- $crate::boxed::Box::<[_]>::into_vec(
- $crate::boxed::Box::slice(
- $crate::boxed::Box::new([$($x),+])
- )
- )
- );
-}
diff --git a/external/vendor/allocator-api2/src/stable/mod.rs b/external/vendor/allocator-api2/src/stable/mod.rs
deleted file mode 100644
index 0f2c9cea..00000000
--- a/external/vendor/allocator-api2/src/stable/mod.rs
+++ /dev/null
@@ -1,105 +0,0 @@
-#![deny(unsafe_op_in_unsafe_fn)]
-#![allow(clippy::needless_doctest_main, clippy::partialeq_ne_impl)]
-
-#[cfg(feature = "alloc")]
-pub use self::slice::SliceExt;
-
-pub mod alloc;
-
-#[cfg(feature = "alloc")]
-pub mod boxed;
-
-#[cfg(feature = "alloc")]
-mod raw_vec;
-
-#[cfg(feature = "alloc")]
-pub mod vec;
-
-#[cfg(feature = "alloc")]
-mod macros;
-
-#[cfg(feature = "alloc")]
-mod slice;
-
-#[cfg(feature = "alloc")]
-mod unique;
-
-/// Allows turning a [`Box<T: Sized, A>`][boxed::Box] into a [`Box<U: ?Sized, A>`][boxed::Box] where `T` can be unsizing-coerced into a `U`.
-///
-/// This is the only way to create an `allocator_api2::boxed::Box` of an unsized type on stable.
-///
-/// With the standard library's `alloc::boxed::Box`, this is done automatically using the unstable unsize traits, but this crate's Box
-/// can't take advantage of that machinery on stable. So, we need to use type inference and the fact that you *can*
-/// still coerce the inner pointer of a box to get the compiler to help us unsize it using this macro.
-///
-/// # Example
-///
-/// ```
-/// use allocator_api2::unsize_box;
-/// use allocator_api2::boxed::Box;
-/// use core::any::Any;
-///
-/// let sized_box: Box<u64> = Box::new(0);
-/// let unsized_box: Box<dyn Any> = unsize_box!(sized_box);
-/// ```
-#[macro_export]
-#[cfg(feature = "alloc")]
-macro_rules! unsize_box {( $boxed:expr $(,)? ) => ({
- let (ptr, allocator) = ::allocator_api2::boxed::Box::into_raw_with_allocator($boxed);
- // we don't want to allow casting to arbitrary type U, but we do want to allow unsize coercion to happen.
- // that's exactly what's happening here -- this is *not* a pointer cast ptr as *mut _, but the compiler
- // *will* allow an unsizing coercion to happen into the `ptr` place, if one is available. And we use _ so that the user can
- // fill in what they want the unsized type to be by annotating the type of the variable this macro will
- // assign its result to.
- let ptr: *mut _ = ptr;
- // SAFETY: see above for why ptr's type can only be something that can be safely coerced.
- // also, ptr just came from a properly allocated box in the same allocator.
- unsafe {
- ::allocator_api2::boxed::Box::from_raw_in(ptr, allocator)
- }
-})}
-
-#[cfg(feature = "alloc")]
-pub mod collections {
- pub use super::raw_vec::{TryReserveError, TryReserveErrorKind};
-}
-
-#[cfg(feature = "alloc")]
-#[track_caller]
-#[inline(always)]
-#[cfg(debug_assertions)]
-unsafe fn assume(v: bool) {
- if !v {
- core::unreachable!()
- }
-}
-
-#[cfg(feature = "alloc")]
-#[track_caller]
-#[inline(always)]
-#[cfg(not(debug_assertions))]
-unsafe fn assume(v: bool) {
- if !v {
- unsafe {
- core::hint::unreachable_unchecked();
- }
- }
-}
-
-#[cfg(feature = "alloc")]
-#[inline(always)]
-fn addr<T>(x: *const T) -> usize {
- #[allow(clippy::useless_transmute, clippy::transmutes_expressible_as_ptr_casts)]
- unsafe {
- core::mem::transmute(x)
- }
-}
-
-#[cfg(feature = "alloc")]
-#[inline(always)]
-fn invalid_mut<T>(addr: usize) -> *mut T {
- #[allow(clippy::useless_transmute, clippy::transmutes_expressible_as_ptr_casts)]
- unsafe {
- core::mem::transmute(addr)
- }
-}
diff --git a/external/vendor/allocator-api2/src/stable/raw_vec.rs b/external/vendor/allocator-api2/src/stable/raw_vec.rs
deleted file mode 100644
index 938c28b0..00000000
--- a/external/vendor/allocator-api2/src/stable/raw_vec.rs
+++ /dev/null
@@ -1,642 +0,0 @@
-use core::alloc::LayoutError;
-use core::mem::{self, ManuallyDrop, MaybeUninit};
-use core::ops::Drop;
-use core::ptr::{self, NonNull};
-use core::slice;
-use core::{cmp, fmt};
-
-use super::{
- alloc::{Allocator, Global, Layout},
- assume,
- boxed::Box,
-};
-
-#[cfg(not(no_global_oom_handling))]
-use super::alloc::handle_alloc_error;
-
-/// The error type for `try_reserve` methods.
-#[derive(Clone, PartialEq, Eq, Debug)]
-pub struct TryReserveError {
- kind: TryReserveErrorKind,
-}
-
-impl TryReserveError {
- /// Details about the allocation that caused the error
- pub fn kind(&self) -> TryReserveErrorKind {
- self.kind.clone()
- }
-}
-
-/// Details of the allocation that caused a `TryReserveError`
-#[derive(Clone, PartialEq, Eq, Debug)]
-pub enum TryReserveErrorKind {
- /// Error due to the computed capacity exceeding the collection's maximum
- /// (usually `isize::MAX` bytes).
- CapacityOverflow,
-
- /// The memory allocator returned an error
- AllocError {
- /// The layout of allocation request that failed
- layout: Layout,
-
- #[doc(hidden)]
- non_exhaustive: (),
- },
-}
-
-use TryReserveErrorKind::*;
-
-impl From<TryReserveErrorKind> for TryReserveError {
- #[inline(always)]
- fn from(kind: TryReserveErrorKind) -> Self {
- Self { kind }
- }
-}
-
-impl From<LayoutError> for TryReserveErrorKind {
- /// Always evaluates to [`TryReserveErrorKind::CapacityOverflow`].
- #[inline(always)]
- fn from(_: LayoutError) -> Self {
- TryReserveErrorKind::CapacityOverflow
- }
-}
-
-impl fmt::Display for TryReserveError {
- fn fmt(
- &self,
- fmt: &mut core::fmt::Formatter<'_>,
- ) -> core::result::Result<(), core::fmt::Error> {
- fmt.write_str("memory allocation failed")?;
- let reason = match self.kind {
- TryReserveErrorKind::CapacityOverflow => {
- " because the computed capacity exceeded the collection's maximum"
- }
- TryReserveErrorKind::AllocError { .. } => {
- " because the memory allocator returned an error"
- }
- };
- fmt.write_str(reason)
- }
-}
-
-#[cfg(feature = "std")]
-impl std::error::Error for TryReserveError {}
-
-#[cfg(not(no_global_oom_handling))]
-enum AllocInit {
- /// The contents of the new memory are uninitialized.
- Uninitialized,
- /// The new memory is guaranteed to be zeroed.
- Zeroed,
-}
-
-/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
-/// a buffer of memory on the heap without having to worry about all the corner cases
-/// involved. This type is excellent for building your own data structures like Vec and VecDeque.
-/// In particular:
-///
-/// * Produces `NonNull::dangling()` on zero-sized types.
-/// * Produces `NonNull::dangling()` on zero-length allocations.
-/// * Avoids freeing `NonNull::dangling()`.
-/// * Catches all overflows in capacity computations (promotes them to "capacity overflow" panics).
-/// * Guards against 32-bit systems allocating more than isize::MAX bytes.
-/// * Guards against overflowing your length.
-/// * Calls `handle_alloc_error` for fallible allocations.
-/// * Contains a `ptr::NonNull` and thus endows the user with all related benefits.
-/// * Uses the excess returned from the allocator to use the largest available capacity.
-///
-/// This type does not in anyway inspect the memory that it manages. When dropped it *will*
-/// free its memory, but it *won't* try to drop its contents. It is up to the user of `RawVec`
-/// to handle the actual things *stored* inside of a `RawVec`.
-///
-/// Note that the excess of a zero-sized types is always infinite, so `capacity()` always returns
-/// `usize::MAX`. This means that you need to be careful when round-tripping this type with a
-/// `Box<[T]>`, since `capacity()` won't yield the length.
-#[allow(missing_debug_implementations)]
-pub(crate) struct RawVec<T, A: Allocator = Global> {
- ptr: NonNull<T>,
- cap: usize,
- alloc: A,
-}
-
-// Safety: RawVec owns both T and A, so sending is safe if
-// sending is safe for T and A.
-unsafe impl<T, A: Allocator> Send for RawVec<T, A>
-where
- T: Send,
- A: Send,
-{
-}
-
-// Safety: RawVec owns both T and A, so sharing is safe if
-// sharing is safe for T and A.
-unsafe impl<T, A: Allocator> Sync for RawVec<T, A>
-where
- T: Sync,
- A: Sync,
-{
-}
-
-impl<T> RawVec<T, Global> {
- /// Creates the biggest possible `RawVec` (on the system heap)
- /// without allocating. If `T` has positive size, then this makes a
- /// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a
- /// `RawVec` with capacity `usize::MAX`. Useful for implementing
- /// delayed allocation.
- #[must_use]
- pub const fn new() -> Self {
- Self::new_in(Global)
- }
-
- /// Creates a `RawVec` (on the system heap) with exactly the
- /// capacity and alignment requirements for a `[T; capacity]`. This is
- /// equivalent to calling `RawVec::new` when `capacity` is `0` or `T` is
- /// zero-sized. Note that if `T` is zero-sized this means you will
- /// *not* get a `RawVec` with the requested capacity.
- ///
- /// # Panics
- ///
- /// Panics if the requested capacity exceeds `isize::MAX` bytes.
- ///
- /// # Aborts
- ///
- /// Aborts on OOM.
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn with_capacity(capacity: usize) -> Self {
- Self::with_capacity_in(capacity, Global)
- }
-
- /// Like `with_capacity`, but guarantees the buffer is zeroed.
- #[cfg(not(no_global_oom_handling))]
- #[must_use]
- #[inline(always)]
- pub fn with_capacity_zeroed(capacity: usize) -> Self {
- Self::with_capacity_zeroed_in(capacity, Global)
- }
-}
-
-impl<T, A: Allocator> RawVec<T, A> {
- // Tiny Vecs are dumb. Skip to:
- // - 8 if the element size is 1, because any heap allocators is likely
- // to round up a request of less than 8 bytes to at least 8 bytes.
- // - 4 if elements are moderate-sized (<= 1 KiB).
- // - 1 otherwise, to avoid wasting too much space for very short Vecs.
- pub(crate) const MIN_NON_ZERO_CAP: usize = if mem::size_of::<T>() == 1 {
- 8
- } else if mem::size_of::<T>() <= 1024 {
- 4
- } else {
- 1
- };
-
- /// Like `new`, but parameterized over the choice of allocator for
- /// the returned `RawVec`.
- #[inline(always)]
- pub const fn new_in(alloc: A) -> Self {
- // `cap: 0` means "unallocated". zero-sized types are ignored.
- Self {
- ptr: NonNull::dangling(),
- cap: 0,
- alloc,
- }
- }
-
- /// Like `with_capacity`, but parameterized over the choice of
- /// allocator for the returned `RawVec`.
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- pub fn with_capacity_in(capacity: usize, alloc: A) -> Self {
- Self::allocate_in(capacity, AllocInit::Uninitialized, alloc)
- }
-
- /// Like `with_capacity_zeroed`, but parameterized over the choice
- /// of allocator for the returned `RawVec`.
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- pub fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self {
- Self::allocate_in(capacity, AllocInit::Zeroed, alloc)
- }
-
- /// Converts the entire buffer into `Box<[MaybeUninit<T>]>` with the specified `len`.
- ///
- /// Note that this will correctly reconstitute any `cap` changes
- /// that may have been performed. (See description of type for details.)
- ///
- /// # Safety
- ///
- /// * `len` must be greater than or equal to the most recently requested capacity, and
- /// * `len` must be less than or equal to `self.capacity()`.
- ///
- /// Note, that the requested capacity and `self.capacity()` could differ, as
- /// an allocator could overallocate and return a greater memory block than requested.
- #[inline(always)]
- pub unsafe fn into_box(self, len: usize) -> Box<[MaybeUninit<T>], A> {
- // Sanity-check one half of the safety requirement (we cannot check the other half).
- debug_assert!(
- len <= self.capacity(),
- "`len` must be smaller than or equal to `self.capacity()`"
- );
-
- let me = ManuallyDrop::new(self);
- unsafe {
- let slice = slice::from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
- Box::<[MaybeUninit<T>], A>::from_raw_in(slice, ptr::read(&me.alloc))
- }
- }
-
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- fn allocate_in(capacity: usize, init: AllocInit, alloc: A) -> Self {
- // Don't allocate here because `Drop` will not deallocate when `capacity` is 0.
- if mem::size_of::<T>() == 0 || capacity == 0 {
- Self::new_in(alloc)
- } else {
- // We avoid `unwrap_or_else` here because it bloats the amount of
- // LLVM IR generated.
- let layout = match Layout::array::<T>(capacity) {
- Ok(layout) => layout,
- Err(_) => capacity_overflow(),
- };
- match alloc_guard(layout.size()) {
- Ok(_) => {}
- Err(_) => capacity_overflow(),
- }
- let result = match init {
- AllocInit::Uninitialized => alloc.allocate(layout),
- AllocInit::Zeroed => alloc.allocate_zeroed(layout),
- };
- let ptr = match result {
- Ok(ptr) => ptr,
- Err(_) => handle_alloc_error(layout),
- };
-
- // Allocators currently return a `NonNull<[u8]>` whose length
- // matches the size requested. If that ever changes, the capacity
- // here should change to `ptr.len() / mem::size_of::<T>()`.
- Self {
- ptr: unsafe { NonNull::new_unchecked(ptr.cast().as_ptr()) },
- cap: capacity,
- alloc,
- }
- }
- }
-
- /// Reconstitutes a `RawVec` from a pointer, capacity, and allocator.
- ///
- /// # Safety
- ///
- /// The `ptr` must be allocated (via the given allocator `alloc`), and with the given
- /// `capacity`.
- /// The `capacity` cannot exceed `isize::MAX` for sized types. (only a concern on 32-bit
- /// systems). ZST vectors may have a capacity up to `usize::MAX`.
- /// If the `ptr` and `capacity` come from a `RawVec` created via `alloc`, then this is
- /// guaranteed.
- #[inline(always)]
- pub unsafe fn from_raw_parts_in(ptr: *mut T, capacity: usize, alloc: A) -> Self {
- Self {
- ptr: unsafe { NonNull::new_unchecked(ptr) },
- cap: capacity,
- alloc,
- }
- }
-
- /// Gets a raw pointer to the start of the allocation. Note that this is
- /// `NonNull::dangling()` if `capacity == 0` or `T` is zero-sized. In the former case, you must
- /// be careful.
- #[inline(always)]
- pub fn ptr(&self) -> *mut T {
- self.ptr.as_ptr()
- }
-
- /// Gets the capacity of the allocation.
- ///
- /// This will always be `usize::MAX` if `T` is zero-sized.
- #[inline(always)]
- pub fn capacity(&self) -> usize {
- if mem::size_of::<T>() == 0 {
- usize::MAX
- } else {
- self.cap
- }
- }
-
- /// Returns a shared reference to the allocator backing this `RawVec`.
- #[inline(always)]
- pub fn allocator(&self) -> &A {
- &self.alloc
- }
-
- #[inline(always)]
- fn current_memory(&self) -> Option<(NonNull<u8>, Layout)> {
- if mem::size_of::<T>() == 0 || self.cap == 0 {
- None
- } else {
- // We have an allocated chunk of memory, so we can bypass runtime
- // checks to get our current layout.
- unsafe {
- let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
- Some((self.ptr.cast(), layout))
- }
- }
- }
-
- /// Ensures that the buffer contains at least enough space to hold `len +
- /// additional` elements. If it doesn't already have enough capacity, will
- /// reallocate enough space plus comfortable slack space to get amortized
- /// *O*(1) behavior. Will limit this behavior if it would needlessly cause
- /// itself to panic.
- ///
- /// If `len` exceeds `self.capacity()`, this may fail to actually allocate
- /// the requested space. This is not really unsafe, but the unsafe
- /// code *you* write that relies on the behavior of this function may break.
- ///
- /// This is ideal for implementing a bulk-push operation like `extend`.
- ///
- /// # Panics
- ///
- /// Panics if the new capacity exceeds `isize::MAX` bytes.
- ///
- /// # Aborts
- ///
- /// Aborts on OOM.
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- pub fn reserve(&mut self, len: usize, additional: usize) {
- // Callers expect this function to be very cheap when there is already sufficient capacity.
- // Therefore, we move all the resizing and error-handling logic from grow_amortized and
- // handle_reserve behind a call, while making sure that this function is likely to be
- // inlined as just a comparison and a call if the comparison fails.
- #[cold]
- #[inline(always)]
- fn do_reserve_and_handle<T, A: Allocator>(
- slf: &mut RawVec<T, A>,
- len: usize,
- additional: usize,
- ) {
- handle_reserve(slf.grow_amortized(len, additional));
- }
-
- if self.needs_to_grow(len, additional) {
- do_reserve_and_handle(self, len, additional);
- }
- }
-
- /// A specialized version of `reserve()` used only by the hot and
- /// oft-instantiated `Vec::push()`, which does its own capacity check.
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- pub fn reserve_for_push(&mut self, len: usize) {
- handle_reserve(self.grow_amortized(len, 1));
- }
-
- /// The same as `reserve`, but returns on errors instead of panicking or aborting.
- #[inline(always)]
- pub fn try_reserve(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> {
- if self.needs_to_grow(len, additional) {
- self.grow_amortized(len, additional)
- } else {
- Ok(())
- }
- }
-
- /// Ensures that the buffer contains at least enough space to hold `len +
- /// additional` elements. If it doesn't already, will reallocate the
- /// minimum possible amount of memory necessary. Generally this will be
- /// exactly the amount of memory necessary, but in principle the allocator
- /// is free to give back more than we asked for.
- ///
- /// If `len` exceeds `self.capacity()`, this may fail to actually allocate
- /// the requested space. This is not really unsafe, but the unsafe code
- /// *you* write that relies on the behavior of this function may break.
- ///
- /// # Panics
- ///
- /// Panics if the new capacity exceeds `isize::MAX` bytes.
- ///
- /// # Aborts
- ///
- /// Aborts on OOM.
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- pub fn reserve_exact(&mut self, len: usize, additional: usize) {
- handle_reserve(self.try_reserve_exact(len, additional));
- }
-
- /// The same as `reserve_exact`, but returns on errors instead of panicking or aborting.
- #[inline(always)]
- pub fn try_reserve_exact(
- &mut self,
- len: usize,
- additional: usize,
- ) -> Result<(), TryReserveError> {
- if self.needs_to_grow(len, additional) {
- self.grow_exact(len, additional)
- } else {
- Ok(())
- }
- }
-
- /// Shrinks the buffer down to the specified capacity. If the given amount
- /// is 0, actually completely deallocates.
- ///
- /// # Panics
- ///
- /// Panics if the given amount is *larger* than the current capacity.
- ///
- /// # Aborts
- ///
- /// Aborts on OOM.
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- pub fn shrink_to_fit(&mut self, cap: usize) {
- handle_reserve(self.shrink(cap));
- }
-}
-
-impl<T, A: Allocator> RawVec<T, A> {
- /// Returns if the buffer needs to grow to fulfill the needed extra capacity.
- /// Mainly used to make inlining reserve-calls possible without inlining `grow`.
- #[inline(always)]
- fn needs_to_grow(&self, len: usize, additional: usize) -> bool {
- additional > self.capacity().wrapping_sub(len)
- }
-
- #[inline(always)]
- fn set_ptr_and_cap(&mut self, ptr: NonNull<[u8]>, cap: usize) {
- // Allocators currently return a `NonNull<[u8]>` whose length matches
- // the size requested. If that ever changes, the capacity here should
- // change to `ptr.len() / mem::size_of::<T>()`.
- self.ptr = unsafe { NonNull::new_unchecked(ptr.cast().as_ptr()) };
- self.cap = cap;
- }
-
- // This method is usually instantiated many times. So we want it to be as
- // small as possible, to improve compile times. But we also want as much of
- // its contents to be statically computable as possible, to make the
- // generated code run faster. Therefore, this method is carefully written
- // so that all of the code that depends on `T` is within it, while as much
- // of the code that doesn't depend on `T` as possible is in functions that
- // are non-generic over `T`.
- #[inline(always)]
- fn grow_amortized(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> {
- // This is ensured by the calling contexts.
- debug_assert!(additional > 0);
-
- if mem::size_of::<T>() == 0 {
- // Since we return a capacity of `usize::MAX` when `elem_size` is
- // 0, getting to here necessarily means the `RawVec` is overfull.
- return Err(CapacityOverflow.into());
- }
-
- // Nothing we can really do about these checks, sadly.
- let required_cap = len.checked_add(additional).ok_or(CapacityOverflow)?;
-
- // This guarantees exponential growth. The doubling cannot overflow
- // because `cap <= isize::MAX` and the type of `cap` is `usize`.
- let cap = cmp::max(self.cap * 2, required_cap);
- let cap = cmp::max(Self::MIN_NON_ZERO_CAP, cap);
-
- let new_layout = Layout::array::<T>(cap);
-
- // `finish_grow` is non-generic over `T`.
- let ptr = finish_grow(new_layout, self.current_memory(), &mut self.alloc)?;
- self.set_ptr_and_cap(ptr, cap);
- Ok(())
- }
-
- // The constraints on this method are much the same as those on
- // `grow_amortized`, but this method is usually instantiated less often so
- // it's less critical.
- #[inline(always)]
- fn grow_exact(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> {
- if mem::size_of::<T>() == 0 {
- // Since we return a capacity of `usize::MAX` when the type size is
- // 0, getting to here necessarily means the `RawVec` is overfull.
- return Err(CapacityOverflow.into());
- }
-
- let cap = len.checked_add(additional).ok_or(CapacityOverflow)?;
- let new_layout = Layout::array::<T>(cap);
-
- // `finish_grow` is non-generic over `T`.
- let ptr = finish_grow(new_layout, self.current_memory(), &mut self.alloc)?;
- self.set_ptr_and_cap(ptr, cap);
- Ok(())
- }
-
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- fn shrink(&mut self, cap: usize) -> Result<(), TryReserveError> {
- assert!(
- cap <= self.capacity(),
- "Tried to shrink to a larger capacity"
- );
-
- let (ptr, layout) = if let Some(mem) = self.current_memory() {
- mem
- } else {
- return Ok(());
- };
-
- let ptr = unsafe {
- // `Layout::array` cannot overflow here because it would have
- // overflowed earlier when capacity was larger.
- let new_layout = Layout::array::<T>(cap).unwrap_unchecked();
- self.alloc
- .shrink(ptr, layout, new_layout)
- .map_err(|_| AllocError {
- layout: new_layout,
- non_exhaustive: (),
- })?
- };
- self.set_ptr_and_cap(ptr, cap);
- Ok(())
- }
-}
-
-// This function is outside `RawVec` to minimize compile times. See the comment
-// above `RawVec::grow_amortized` for details. (The `A` parameter isn't
-// significant, because the number of different `A` types seen in practice is
-// much smaller than the number of `T` types.)
-#[inline(always)]
-fn finish_grow<A>(
- new_layout: Result<Layout, LayoutError>,
- current_memory: Option<(NonNull<u8>, Layout)>,
- alloc: &mut A,
-) -> Result<NonNull<[u8]>, TryReserveError>
-where
- A: Allocator,
-{
- // Check for the error here to minimize the size of `RawVec::grow_*`.
- let new_layout = new_layout.map_err(|_| CapacityOverflow)?;
-
- alloc_guard(new_layout.size())?;
-
- let memory = if let Some((ptr, old_layout)) = current_memory {
- debug_assert_eq!(old_layout.align(), new_layout.align());
- unsafe {
- // The allocator checks for alignment equality
- assume(old_layout.align() == new_layout.align());
- alloc.grow(ptr, old_layout, new_layout)
- }
- } else {
- alloc.allocate(new_layout)
- };
-
- memory.map_err(|_| {
- AllocError {
- layout: new_layout,
- non_exhaustive: (),
- }
- .into()
- })
-}
-
-impl<T, A: Allocator> Drop for RawVec<T, A> {
- /// Frees the memory owned by the `RawVec` *without* trying to drop its contents.
- #[inline(always)]
- fn drop(&mut self) {
- if let Some((ptr, layout)) = self.current_memory() {
- unsafe { self.alloc.deallocate(ptr, layout) }
- }
- }
-}
-
-// Central function for reserve error handling.
-#[cfg(not(no_global_oom_handling))]
-#[inline(always)]
-fn handle_reserve(result: Result<(), TryReserveError>) {
- match result.map_err(|e| e.kind()) {
- Err(CapacityOverflow) => capacity_overflow(),
- Err(AllocError { layout, .. }) => handle_alloc_error(layout),
- Ok(()) => { /* yay */ }
- }
-}
-
-// We need to guarantee the following:
-// * We don't ever allocate `> isize::MAX` byte-size objects.
-// * We don't overflow `usize::MAX` and actually allocate too little.
-//
-// On 64-bit we just need to check for overflow since trying to allocate
-// `> isize::MAX` bytes will surely fail. On 32-bit and 16-bit we need to add
-// an extra guard for this in case we're running on a platform which can use
-// all 4GB in user-space, e.g., PAE or x32.
-
-#[inline(always)]
-fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
- if usize::BITS < 64 && alloc_size > isize::MAX as usize {
- Err(CapacityOverflow.into())
- } else {
- Ok(())
- }
-}
-
-// One central function responsible for reporting capacity overflows. This'll
-// ensure that the code generation related to these panics is minimal as there's
-// only one location which panics rather than a bunch throughout the module.
-#[cfg(not(no_global_oom_handling))]
-fn capacity_overflow() -> ! {
- panic!("capacity overflow");
-}
diff --git a/external/vendor/allocator-api2/src/stable/slice.rs b/external/vendor/allocator-api2/src/stable/slice.rs
deleted file mode 100644
index 82b2d80d..00000000
--- a/external/vendor/allocator-api2/src/stable/slice.rs
+++ /dev/null
@@ -1,171 +0,0 @@
-use crate::{
- alloc::{Allocator, Global},
- vec::Vec,
-};
-
-/// Slice methods that use `Box` and `Vec` from this crate.
-pub trait SliceExt<T> {
- /// Copies `self` into a new `Vec`.
- ///
- /// # Examples
- ///
- /// ```
- /// let s = [10, 40, 30];
- /// let x = s.to_vec();
- /// // Here, `s` and `x` can be modified independently.
- /// ```
- #[cfg(not(no_global_oom_handling))]
- #[inline(always)]
- fn to_vec(&self) -> Vec<T, Global>
- where
- T: Clone,
- {
- self.to_vec_in(Global)
- }
-
- /// Copies `self` into a new `Vec` with an allocator.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(allocator_api)]
- ///
- /// use std::alloc::System;
- ///
- /// let s = [10, 40, 30];
- /// let x = s.to_vec_in(System);
- /// // Here, `s` and `x` can be modified independently.
- /// ```
- #[cfg(not(no_global_oom_handling))]
- fn to_vec_in<A: Allocator>(&self, alloc: A) -> Vec<T, A>
- where
- T: Clone;
-
- /// Creates a vector by copying a slice `n` times.
- ///
- /// # Panics
- ///
- /// This function will panic if the capacity would overflow.
- ///
- /// # Examples
- ///
- /// Basic usage:
- ///
- /// ```
- /// assert_eq!([1, 2].repeat(3), vec![1, 2, 1, 2, 1, 2]);
- /// ```
- ///
- /// A panic upon overflow:
- ///
- /// ```should_panic
- /// // this will panic at runtime
- /// b"0123456789abcdef".repeat(usize::MAX);
- /// ```
- fn repeat(&self, n: usize) -> Vec<T, Global>
- where
- T: Copy;
-}
-
-impl<T> SliceExt<T> for [T] {
- #[cfg(not(no_global_oom_handling))]
- #[inline]
- fn to_vec_in<A: Allocator>(&self, alloc: A) -> Vec<T, A>
- where
- T: Clone,
- {
- struct DropGuard<'a, T, A: Allocator> {
- vec: &'a mut Vec<T, A>,
- num_init: usize,
- }
- impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> {
- #[inline]
- fn drop(&mut self) {
- // SAFETY:
- // items were marked initialized in the loop below
- unsafe {
- self.vec.set_len(self.num_init);
- }
- }
- }
-
- let mut vec = Vec::with_capacity_in(self.len(), alloc);
- let mut guard = DropGuard {
- vec: &mut vec,
- num_init: 0,
- };
- let slots = guard.vec.spare_capacity_mut();
- // .take(slots.len()) is necessary for LLVM to remove bounds checks
- // and has better codegen than zip.
- for (i, b) in self.iter().enumerate().take(slots.len()) {
- guard.num_init = i;
- slots[i].write(b.clone());
- }
- core::mem::forget(guard);
- // SAFETY:
- // the vec was allocated and initialized above to at least this length.
- unsafe {
- vec.set_len(self.len());
- }
- vec
- }
-
- #[cfg(not(no_global_oom_handling))]
- #[inline]
- fn repeat(&self, n: usize) -> Vec<T, Global>
- where
- T: Copy,
- {
- if n == 0 {
- return Vec::new();
- }
-
- // If `n` is larger than zero, it can be split as
- // `n = 2^expn + rem (2^expn > rem, expn >= 0, rem >= 0)`.
- // `2^expn` is the number represented by the leftmost '1' bit of `n`,
- // and `rem` is the remaining part of `n`.
-
- // Using `Vec` to access `set_len()`.
- let capacity = self.len().checked_mul(n).expect("capacity overflow");
- let mut buf = Vec::with_capacity(capacity);
-
- // `2^expn` repetition is done by doubling `buf` `expn`-times.
- buf.extend(self);
- {
- let mut m = n >> 1;
- // If `m > 0`, there are remaining bits up to the leftmost '1'.
- while m > 0 {
- // `buf.extend(buf)`:
- unsafe {
- core::ptr::copy_nonoverlapping(
- buf.as_ptr(),
- (buf.as_mut_ptr() as *mut T).add(buf.len()),
- buf.len(),
- );
- // `buf` has capacity of `self.len() * n`.
- let buf_len = buf.len();
- buf.set_len(buf_len * 2);
- }
-
- m >>= 1;
- }
- }
-
- // `rem` (`= n - 2^expn`) repetition is done by copying
- // first `rem` repetitions from `buf` itself.
- let rem_len = capacity - buf.len(); // `self.len() * rem`
- if rem_len > 0 {
- // `buf.extend(buf[0 .. rem_len])`:
- unsafe {
- // This is non-overlapping since `2^expn > rem`.
- core::ptr::copy_nonoverlapping(
- buf.as_ptr(),
- (buf.as_mut_ptr() as *mut T).add(buf.len()),
- rem_len,
- );
- // `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`).
- buf.set_len(capacity);
- }
- }
- buf
- }
-}
diff --git a/external/vendor/allocator-api2/src/stable/unique.rs b/external/vendor/allocator-api2/src/stable/unique.rs
deleted file mode 100644
index 6768a3d9..00000000
--- a/external/vendor/allocator-api2/src/stable/unique.rs
+++ /dev/null
@@ -1,106 +0,0 @@
-/// A wrapper around a raw non-null `*mut T` that indicates that the possessor
-/// of this wrapper owns the referent. Useful for building abstractions like
-/// `Box<T>`, `Vec<T>`, `String`, and `HashMap<K, V>`.
-///
-/// Unlike `*mut T`, `Unique<T>` behaves "as if" it were an instance of `T`.
-/// It implements `Send`/`Sync` if `T` is `Send`/`Sync`. It also implies
-/// the kind of strong aliasing guarantees an instance of `T` can expect:
-/// the referent of the pointer should not be modified without a unique path to
-/// its owning Unique.
-///
-/// If you're uncertain of whether it's correct to use `Unique` for your purposes,
-/// consider using `NonNull`, which has weaker semantics.
-///
-/// Unlike `*mut T`, the pointer must always be non-null, even if the pointer
-/// is never dereferenced. This is so that enums may use this forbidden value
-/// as a discriminant -- `Option<Unique<T>>` has the same size as `Unique<T>`.
-/// However the pointer may still dangle if it isn't dereferenced.
-///
-/// Unlike `*mut T`, `Unique<T>` is covariant over `T`. This should always be correct
-/// for any type which upholds Unique's aliasing requirements.
-#[repr(transparent)]
-pub(crate) struct Unique<T: ?Sized> {
- pointer: NonNull<T>,
- _marker: PhantomData<T>,
-}
-
-/// `Unique` pointers are `Send` if `T` is `Send` because the data they
-/// reference is unaliased. Note that this aliasing invariant is
-/// unenforced by the type system; the abstraction using the
-/// `Unique` must enforce it.
-unsafe impl<T: Send + ?Sized> Send for Unique<T> {}
-
-/// `Unique` pointers are `Sync` if `T` is `Sync` because the data they
-/// reference is unaliased. Note that this aliasing invariant is
-/// unenforced by the type system; the abstraction using the
-/// `Unique` must enforce it.
-unsafe impl<T: Sync + ?Sized> Sync for Unique<T> {}
-
-impl<T: ?Sized> Unique<T> {
- /// Creates a new `Unique`.
- ///
- /// # Safety
- ///
- /// `ptr` must be non-null.
- #[inline]
- pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
- // SAFETY: the caller must guarantee that `ptr` is non-null.
- unsafe {
- Unique {
- pointer: NonNull::new_unchecked(ptr),
- _marker: PhantomData,
- }
- }
- }
-
- /// Acquires the underlying `*mut` pointer.
- #[must_use = "`self` will be dropped if the result is not used"]
- #[inline]
- pub const fn as_ptr(self) -> *mut T {
- self.pointer.as_ptr()
- }
-
- /// Acquires the underlying `*mut` pointer.
- #[must_use = "`self` will be dropped if the result is not used"]
- #[inline]
- pub const fn as_non_null_ptr(self) -> NonNull<T> {
- self.pointer
- }
-
- /// Dereferences the content.
- ///
- /// The resulting lifetime is bound to self so this behaves "as if"
- /// it were actually an instance of T that is getting borrowed. If a longer
- /// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
- #[must_use]
- #[inline]
- pub const unsafe fn as_ref(&self) -> &T {
- // SAFETY: the caller must guarantee that `self` meets all the
- // requirements for a reference.
- unsafe { &*(self.as_ptr() as *const T) }
- }
-
- /// Mutably dereferences the content.
- ///
- /// The resulting lifetime is bound to self so this behaves "as if"
- /// it were actually an instance of T that is getting borrowed. If a longer
- /// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
- #[must_use]
- #[inline]
- pub unsafe fn as_mut(&mut self) -> &mut T {
- // SAFETY: the caller must guarantee that `self` meets all the
- // requirements for a mutable reference.
- unsafe { self.pointer.as_mut() }
- }
-}
-
-impl<T: ?Sized> Clone for Unique<T> {
- #[inline]
- fn clone(&self) -> Self {
- *self
- }
-}
-
-impl<T: ?Sized> Copy for Unique<T> {}
-
-use core::{marker::PhantomData, ptr::NonNull};
diff --git a/external/vendor/allocator-api2/src/stable/vec/drain.rs b/external/vendor/allocator-api2/src/stable/vec/drain.rs
deleted file mode 100644
index d3b962f7..00000000
--- a/external/vendor/allocator-api2/src/stable/vec/drain.rs
+++ /dev/null
@@ -1,242 +0,0 @@
-use core::fmt;
-use core::iter::FusedIterator;
-use core::mem::{self, size_of, ManuallyDrop};
-use core::ptr::{self, NonNull};
-use core::slice::{self};
-
-use crate::stable::alloc::{Allocator, Global};
-
-use super::Vec;
-
-/// A draining iterator for `Vec<T>`.
-///
-/// This `struct` is created by [`Vec::drain`].
-/// See its documentation for more.
-///
-/// # Example
-///
-/// ```
-/// let mut v = vec![0, 1, 2];
-/// let iter: std::vec::Drain<_> = v.drain(..);
-/// ```
-pub struct Drain<'a, T: 'a, A: Allocator + 'a = Global> {
- /// Index of tail to preserve
- pub(super) tail_start: usize,
- /// Length of tail
- pub(super) tail_len: usize,
- /// Current remaining range to remove
- pub(super) iter: slice::Iter<'a, T>,
- pub(super) vec: NonNull<Vec<T, A>>,
-}
-
-impl<T: fmt::Debug, A: Allocator> fmt::Debug for Drain<'_, T, A> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.debug_tuple("Drain").field(&self.iter.as_slice()).finish()
- }
-}
-
-impl<'a, T, A: Allocator> Drain<'a, T, A> {
- /// Returns the remaining items of this iterator as a slice.
- ///
- /// # Examples
- ///
- /// ```
- /// let mut vec = vec!['a', 'b', 'c'];
- /// let mut drain = vec.drain(..);
- /// assert_eq!(drain.as_slice(), &['a', 'b', 'c']);
- /// let _ = drain.next().unwrap();
- /// assert_eq!(drain.as_slice(), &['b', 'c']);
- /// ```
- #[must_use]
- #[inline(always)]
- pub fn as_slice(&self) -> &[T] {
- self.iter.as_slice()
- }
-
- /// Returns a reference to the underlying allocator.
- #[must_use]
- #[inline(always)]
- pub fn allocator(&self) -> &A {
- unsafe { self.vec.as_ref().allocator() }
- }
-
- /// Keep unyielded elements in the source `Vec`.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(drain_keep_rest)]
- ///
- /// let mut vec = vec!['a', 'b', 'c'];
- /// let mut drain = vec.drain(..);
- ///
- /// assert_eq!(drain.next().unwrap(), 'a');
- ///
- /// // This call keeps 'b' and 'c' in the vec.
- /// drain.keep_rest();
- ///
- /// // If we wouldn't call `keep_rest()`,
- /// // `vec` would be empty.
- /// assert_eq!(vec, ['b', 'c']);
- /// ```
- #[inline(always)]
- pub fn keep_rest(self) {
- // At this moment layout looks like this:
- //
- // [head] [yielded by next] [unyielded] [yielded by next_back] [tail]
- // ^-- start \_________/-- unyielded_len \____/-- self.tail_len
- // ^-- unyielded_ptr ^-- tail
- //
- // Normally `Drop` impl would drop [unyielded] and then move [tail] to the `start`.
- // Here we want to
- // 1. Move [unyielded] to `start`
- // 2. Move [tail] to a new start at `start + len(unyielded)`
- // 3. Update length of the original vec to `len(head) + len(unyielded) + len(tail)`
- // a. In case of ZST, this is the only thing we want to do
- // 4. Do *not* drop self, as everything is put in a consistent state already, there is nothing to do
- let mut this = ManuallyDrop::new(self);
-
- unsafe {
- let source_vec = this.vec.as_mut();
-
- let start = source_vec.len();
- let tail = this.tail_start;
-
- let unyielded_len = this.iter.len();
- let unyielded_ptr = this.iter.as_slice().as_ptr();
-
- // ZSTs have no identity, so we don't need to move them around.
- let needs_move = mem::size_of::<T>() != 0;
-
- if needs_move {
- let start_ptr = source_vec.as_mut_ptr().add(start);
-
- // memmove back unyielded elements
- if unyielded_ptr != start_ptr {
- let src = unyielded_ptr;
- let dst = start_ptr;
-
- ptr::copy(src, dst, unyielded_len);
- }
-
- // memmove back untouched tail
- if tail != (start + unyielded_len) {
- let src = source_vec.as_ptr().add(tail);
- let dst = start_ptr.add(unyielded_len);
- ptr::copy(src, dst, this.tail_len);
- }
- }
-
- source_vec.set_len(start + unyielded_len + this.tail_len);
- }
- }
-}
-
-impl<'a, T, A: Allocator> AsRef<[T]> for Drain<'a, T, A> {
- #[inline(always)]
- fn as_ref(&self) -> &[T] {
- self.as_slice()
- }
-}
-
-unsafe impl<T: Sync, A: Sync + Allocator> Sync for Drain<'_, T, A> {}
-
-unsafe impl<T: Send, A: Send + Allocator> Send for Drain<'_, T, A> {}
-
-impl<T, A: Allocator> Iterator for Drain<'_, T, A> {
- type Item = T;
-
- #[inline(always)]
- fn next(&mut self) -> Option<T> {
- self.iter
- .next()
- .map(|elt| unsafe { ptr::read(elt as *const _) })
- }
-
- #[inline(always)]
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.iter.size_hint()
- }
-}
-
-impl<T, A: Allocator> DoubleEndedIterator for Drain<'_, T, A> {
- #[inline(always)]
- fn next_back(&mut self) -> Option<T> {
- self.iter
- .next_back()
- .map(|elt| unsafe { ptr::read(elt as *const _) })
- }
-}
-
-impl<T, A: Allocator> Drop for Drain<'_, T, A> {
- #[inline]
- fn drop(&mut self) {
- /// Moves back the un-`Drain`ed elements to restore the original `Vec`.
- struct DropGuard<'r, 'a, T, A: Allocator>(&'r mut Drain<'a, T, A>);
-
- impl<'r, 'a, T, A: Allocator> Drop for DropGuard<'r, 'a, T, A> {
- fn drop(&mut self) {
- if self.0.tail_len > 0 {
- unsafe {
- let source_vec = self.0.vec.as_mut();
- // memmove back untouched tail, update to new length
- let start = source_vec.len();
- let tail = self.0.tail_start;
- if tail != start {
- let src = source_vec.as_ptr().add(tail);
- let dst = source_vec.as_mut_ptr().add(start);
- ptr::copy(src, dst, self.0.tail_len);
- }
- source_vec.set_len(start + self.0.tail_len);
- }
- }
- }
- }
-
- let iter = mem::replace(&mut self.iter, [].iter());
- let drop_len = iter.len();
-
- let mut vec = self.vec;
-
- if size_of::<T>() == 0 {
- // ZSTs have no identity, so we don't need to move them around, we only need to drop the correct amount.
- // this can be achieved by manipulating the Vec length instead of moving values out from `iter`.
- unsafe {
- let vec = vec.as_mut();
- let old_len = vec.len();
- vec.set_len(old_len + drop_len + self.tail_len);
- vec.truncate(old_len + self.tail_len);
- }
-
- return;
- }
-
- // ensure elements are moved back into their appropriate places, even when drop_in_place panics
- let _guard = DropGuard(self);
-
- if drop_len == 0 {
- return;
- }
-
- // as_slice() must only be called when iter.len() is > 0 because
- // vec::Splice modifies vec::Drain fields and may grow the vec which would invalidate
- // the iterator's internal pointers. Creating a reference to deallocated memory
- // is invalid even when it is zero-length
- let drop_ptr = iter.as_slice().as_ptr();
-
- unsafe {
- // drop_ptr comes from a slice::Iter which only gives us a &[T] but for drop_in_place
- // a pointer with mutable provenance is necessary. Therefore we must reconstruct
- // it from the original vec but also avoid creating a &mut to the front since that could
- // invalidate raw pointers to it which some unsafe code might rely on.
- let vec_ptr = vec.as_mut().as_mut_ptr();
- let drop_offset = drop_ptr.offset_from(vec_ptr) as usize;
- let to_drop = ptr::slice_from_raw_parts_mut(vec_ptr.add(drop_offset), drop_len);
- ptr::drop_in_place(to_drop);
- }
- }
-}
-
-impl<T, A: Allocator> ExactSizeIterator for Drain<'_, T, A> {}
-
-impl<T, A: Allocator> FusedIterator for Drain<'_, T, A> {}
diff --git a/external/vendor/allocator-api2/src/stable/vec/into_iter.rs b/external/vendor/allocator-api2/src/stable/vec/into_iter.rs
deleted file mode 100644
index 653ccdbf..00000000
--- a/external/vendor/allocator-api2/src/stable/vec/into_iter.rs
+++ /dev/null
@@ -1,191 +0,0 @@
-use core::fmt;
-use core::iter::FusedIterator;
-use core::marker::PhantomData;
-use core::mem::{self, size_of, ManuallyDrop};
-
-use core::ptr::{self, NonNull};
-use core::slice::{self};
-
-use crate::stable::addr;
-
-use super::{Allocator, Global, RawVec};
-
-#[cfg(not(no_global_oom_handling))]
-use super::Vec;
-
-/// An iterator that moves out of a vector.
-///
-/// This `struct` is created by the `into_iter` method on [`Vec`](super::Vec)
-/// (provided by the [`IntoIterator`] trait).
-///
-/// # Example
-///
-/// ```
-/// let v = vec![0, 1, 2];
-/// let iter: std::vec::IntoIter<_> = v.into_iter();
-/// ```
-pub struct IntoIter<T, A: Allocator = Global> {
- pub(super) buf: NonNull<T>,
- pub(super) phantom: PhantomData<T>,Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.