Roll zerotrie: 0.2.0 => 0.2.1 in //third_party/rust.
This CL has been created semi-automatically. The expected review
process and other details can be found at
//tools/crates/create_update_cl.md
Updated crates:
* zerotrie: 0.2.0 => 0.2.1
New crates:
* yoke-derive@0.8.0
* yoke@0.8.0
Chromium `supply-chain/config.toml` policy requires that the following
audit criteria are met (note that these are the *minimum* required
criteria and `supply-chain/audits.toml` can and should record a stricter
certification if possible; see also //docs/rust-unsafe.md):
* yoke-derive@0.8.0, yoke@0.8.0, zerotrie@0.2.1: crypto-safe,
safe-to-deploy, ub-risk-2
Bug: None
Change-Id: Ib4e14ce5e3b52fc8cd0d494040239afe3629027b
Cq-Include-Trybots: chromium/try:android-rust-arm32-rel
Cq-Include-Trybots: chromium/try:android-rust-arm64-dbg
Cq-Include-Trybots: chromium/try:android-rust-arm64-rel
Cq-Include-Trybots: chromium/try:linux-rust-x64-dbg
Cq-Include-Trybots: chromium/try:linux-rust-x64-rel
Cq-Include-Trybots: chromium/try:win-rust-x64-dbg
Cq-Include-Trybots: chromium/try:win-rust-x64-rel
Disable-Rts: True
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6323349
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Ćukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1429820}
diff --git a/third_party/rust/chromium_crates_io/Cargo.lock b/third_party/rust/chromium_crates_io/Cargo.lock
index 6c96a91..2787494 100644
--- a/third_party/rust/chromium_crates_io/Cargo.lock
+++ b/third_party/rust/chromium_crates_io/Cargo.lock
@@ -486,7 +486,7 @@
dependencies = [
"displaydoc",
"potential_utf",
- "yoke",
+ "yoke 0.7.5",
"zerofrom",
"zerovec",
]
@@ -676,7 +676,7 @@
"displaydoc",
"either",
"writeable",
- "yoke",
+ "yoke 0.7.5",
"zerovec",
]
@@ -736,7 +736,7 @@
"stable_deref_trait",
"tinystr",
"writeable",
- "yoke",
+ "yoke 0.7.5",
"zerofrom",
"zerovec",
]
@@ -1461,7 +1461,17 @@
dependencies = [
"serde",
"stable_deref_trait",
- "yoke-derive",
+ "yoke-derive 0.7.5",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "stable_deref_trait",
+ "yoke-derive 0.8.0",
"zerofrom",
]
@@ -1477,6 +1487,17 @@
]
[[package]]
+name = "yoke-derive"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
name = "zerocopy"
version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1516,11 +1537,11 @@
[[package]]
name = "zerotrie"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"displaydoc",
- "yoke",
+ "yoke 0.8.0",
"zerofrom",
]
@@ -1529,7 +1550,7 @@
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "yoke",
+ "yoke 0.7.5",
"zerofrom",
"zerovec-derive",
]
diff --git a/third_party/rust/chromium_crates_io/supply-chain/audits.toml b/third_party/rust/chromium_crates_io/supply-chain/audits.toml
index 31e967c..3efb5817 100644
--- a/third_party/rust/chromium_crates_io/supply-chain/audits.toml
+++ b/third_party/rust/chromium_crates_io/supply-chain/audits.toml
@@ -3786,12 +3786,31 @@
criteria = ["safe-to-deploy", "does-not-implement-crypto"]
version = "0.7.5"
+[[audits.yoke]]
+who = "Daniel Cheng <dcheng@chromium.org>"
+criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
+delta = "0.7.5 -> 0.8.0"
+notes = """
+Cleaning up a previous hack for adding trait bounds to yoke objects. Unsafe changes:
+- deleting the hack itself removes a lot of unsafe use required in the hack's implementation
+- changes another unsafe use to remove the use of the hack, now that it's no longer needed
+
+
+See https://crrev.com/c/6323349 for more audit notes.
+"""
+
[[audits.yoke-derive]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
version = "0.7.5"
notes = "Custom derive implementing the `Yokeable` trait. Generally generates simple code that asserts covariance."
+[[audits.yoke-derive]]
+who = "Daniel Cheng <dcheng@chromium.org>"
+criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
+delta = "0.7.5 -> 0.8.0"
+notes = "No code changes: only incrementing the version."
+
[[audits.zerofrom]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
@@ -3822,6 +3841,17 @@
version = "0.2.0"
notes = "Minor repr(transparent) unsafe code. Improved comments in https://github.com/unicode-org/icu4x/pull/6054"
+[[audits.zerotrie]]
+who = "Daniel Cheng <dcheng@chromium.org>"
+criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
+delta = "0.2.0 -> 0.2.1"
+notes = """
+Changes in unsafe blocks are wrapping direct calls to `core::mem::transmute` with the `transparent_ref_from_store` wrapper.
+No safety guarantees change, but providing the `transparent_ref_from_store` as a wrapper provides a convenient marker that this transmute operation is actually sound.
+
+See https://crrev.com/c/6323349 for more audit notes.
+"""
+
[[audits.zerovec]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = "does-not-implement-crypto"
diff --git a/third_party/rust/chromium_crates_io/supply-chain/config.toml b/third_party/rust/chromium_crates_io/supply-chain/config.toml
index 4c2fabf..05ae1d9 100644
--- a/third_party/rust/chromium_crates_io/supply-chain/config.toml
+++ b/third_party/rust/chromium_crates_io/supply-chain/config.toml
@@ -536,9 +536,15 @@
[policy."yoke-derive:0.7.5"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
+[policy."yoke-derive:0.8.0"]
+criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
+
[policy."yoke:0.7.5"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
+[policy."yoke:0.8.0"]
+criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
+
[policy."zerocopy-derive:0.7.35"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@@ -551,7 +557,7 @@
[policy."zerofrom:0.1.6"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
-[policy."zerotrie:0.2.0"]
+[policy."zerotrie:0.2.1"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."zerovec-derive:0.11.1"]
@@ -845,19 +851,6 @@
https://crbug.com/366411886
"""
-[[exemptions.yoke-derive]]
-version = "0.7.5"
-criteria = ["safe-to-deploy", "ub-risk-2"]
-notes = """
-Requires unsafe review audit. Unsafe code is either authored or reviewed by a
-crabal member, but a formal audit is yet to be performed.
-
-Part of Google-co-maintained ICU4X project.
-
-
-https://crbug.com/366411886
-"""
-
[[exemptions.zerocopy]]
version = "0.7.35"
criteria = ["safe-to-deploy", "crypto-safe", "ub-risk-2"]
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/.cargo-checksum.json
similarity index 100%
copy from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo-checksum.json
copy to third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/.cargo-checksum.json
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/.cargo_vcs_info.json
new file mode 100644
index 0000000..3688ce6
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+ "git": {
+ "sha1": "f4290a877dfcb0f87cad6de4abdd65f0cbb33c9c"
+ },
+ "path_in_vcs": "utils/yoke"
+}
\ No newline at end of file
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.lock b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.lock
new file mode 100644
index 0000000..920e69a5
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.lock
@@ -0,0 +1,145 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "bincode"
+version = "1.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "cobs"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
+
+[[package]]
+name = "postcard"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
+dependencies = [
+ "cobs",
+ "serde",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.218"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.218"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
+
+[[package]]
+name = "syn"
+version = "2.0.98"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "synstructure"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
+
+[[package]]
+name = "yoke"
+version = "0.8.0"
+dependencies = [
+ "bincode",
+ "postcard",
+ "serde",
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.toml
new file mode 100644
index 0000000..0cd3bac
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.toml
@@ -0,0 +1,118 @@
+# 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 = "2021"
+rust-version = "1.81"
+name = "yoke"
+version = "0.8.0"
+authors = ["Manish Goregaokar <manishsmail@gmail.com>"]
+build = false
+include = [
+ "data/**/*",
+ "src/**/*",
+ "examples/**/*",
+ "benches/**/*",
+ "tests/**/*",
+ "Cargo.toml",
+ "LICENSE",
+ "README.md",
+]
+autolib = false
+autobins = false
+autoexamples = false
+autotests = false
+autobenches = false
+description = "Abstraction allowing borrowed data to be carried along with the backing data it borrows from"
+readme = "README.md"
+keywords = [
+ "zerocopy",
+ "serialization",
+ "lifetime",
+ "borrow",
+ "self-referential",
+]
+categories = [
+ "data-structures",
+ "memory-management",
+ "caching",
+ "no-std",
+]
+license = "Unicode-3.0"
+repository = "https://github.com/unicode-org/icu4x"
+
+[package.metadata.cargo-all-features]
+max_combination_size = 3
+
+[package.metadata.docs.rs]
+all-features = true
+
+[package.metadata.workspaces]
+independent = true
+
+[features]
+alloc = [
+ "stable_deref_trait/alloc",
+ "serde?/alloc",
+ "zerofrom/alloc",
+]
+default = [
+ "alloc",
+ "zerofrom",
+]
+derive = [
+ "dep:yoke-derive",
+ "zerofrom/derive",
+]
+serde = ["dep:serde"]
+zerofrom = ["dep:zerofrom"]
+
+[lib]
+name = "yoke"
+path = "src/lib.rs"
+
+[[test]]
+name = "bincode"
+path = "tests/bincode.rs"
+
+[[test]]
+name = "miri"
+path = "tests/miri.rs"
+
+[dependencies.serde]
+version = "1.0.110"
+optional = true
+default-features = false
+
+[dependencies.stable_deref_trait]
+version = "1.2.0"
+default-features = false
+
+[dependencies.yoke-derive]
+version = "0.8.0"
+optional = true
+default-features = false
+
+[dependencies.zerofrom]
+version = "0.1.3"
+optional = true
+default-features = false
+
+[dev-dependencies.bincode]
+version = "1.3.1"
+
+[dev-dependencies.postcard]
+version = "1.0.3"
+default-features = false
+
+[dev-dependencies.serde]
+version = "1.0.110"
+default-features = false
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.toml.orig
new file mode 100644
index 0000000..88dfc3c
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/Cargo.toml.orig
@@ -0,0 +1,47 @@
+# This file is part of ICU4X. For terms of use, please see the file
+# called LICENSE at the top level of the ICU4X source tree
+# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+[package]
+name = "yoke"
+description = "Abstraction allowing borrowed data to be carried along with the backing data it borrows from"
+version = "0.8.0"
+authors = ["Manish Goregaokar <manishsmail@gmail.com>"]
+categories = ["data-structures", "memory-management", "caching", "no-std"]
+keywords = ["zerocopy", "serialization", "lifetime", "borrow", "self-referential"]
+
+edition.workspace = true
+include.workspace = true
+license.workspace = true
+repository.workspace = true
+rust-version.workspace = true
+
+[package.metadata.workspaces]
+independent = true
+
+[features]
+default = ["alloc", "zerofrom"]
+derive = ["dep:yoke-derive", "zerofrom/derive"]
+alloc = ["stable_deref_trait/alloc", "serde?/alloc", "zerofrom/alloc"]
+serde = ["dep:serde"]
+zerofrom = ["dep:zerofrom"]
+
+[package.metadata.docs.rs]
+all-features = true
+
+[package.metadata.cargo-all-features]
+# We have tons of features here, limit the amount of tests we run
+max_combination_size = 3
+
+[dependencies]
+stable_deref_trait = { workspace = true }
+
+yoke-derive = { workspace = true, optional = true }
+
+serde = { workspace = true, optional = true }
+zerofrom = { workspace = true, optional = true}
+
+[dev-dependencies]
+bincode = { workspace = true }
+postcard = { workspace = true }
+serde = { workspace = true }
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/LICENSE
similarity index 100%
copy from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE
copy to third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/LICENSE
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/README.md b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/README.md
new file mode 100644
index 0000000..23c1ac8
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/README.md
@@ -0,0 +1,31 @@
+# yoke [](https://crates.io/crates/yoke)
+
+<!-- cargo-rdme start -->
+
+This crate provides [`Yoke<Y, C>`][Yoke], which allows one to "yoke" (attach) a zero-copy deserialized
+object (say, a [`Cow<'a, str>`](alloc::borrow::Cow)) to the source it was deserialized from, (say, an [`Rc<[u8]>`](alloc::rc::Rc)),
+known in this crate as a "cart", producing a type that looks like `Yoke<Cow<'static, str>, Rc<[u8]>>`
+and can be moved around with impunity.
+
+Succinctly, this allows one to "erase" static lifetimes and turn them into dynamic ones, similarly
+to how `dyn` allows one to "erase" static types and turn them into dynamic ones.
+
+Most of the time the yokeable `Y` type will be some kind of zero-copy deserializable
+abstraction, potentially with an owned variant (like [`Cow`](alloc::borrow::Cow),
+[`ZeroVec`](https://docs.rs/zerovec), or an aggregate containing such types), and the cart `C` will be some smart pointer like
+ [`Box<T>`](alloc::boxed::Box), [`Rc<T>`](alloc::rc::Rc), or [`Arc<T>`](std::sync::Arc), potentially wrapped in an [`Option<T>`](Option).
+
+The key behind this crate is [`Yoke::get()`], where calling [`.get()`][Yoke::get] on a type like
+`Yoke<Cow<'static, str>, _>` will get you a short-lived `&'a Cow<'a, str>`, restricted to the
+lifetime of the borrow used during [`.get()`](Yoke::get). This is entirely safe since the `Cow` borrows from
+the cart type `C`, which cannot be interfered with as long as the `Yoke` is borrowed by [`.get()`](Yoke::get).
+[`.get()`](Yoke::get) protects access by essentially reifying the erased lifetime to a safe local one
+when necessary.
+
+See the documentation of [`Yoke`] for more details.
+
+<!-- cargo-rdme end -->
+
+## More Information
+
+For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/cartable_ptr.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/cartable_ptr.rs
new file mode 100644
index 0000000..24bf6d3
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/cartable_ptr.rs
@@ -0,0 +1,445 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! Types for optional pointers with niche optimization.
+//!
+//! The main type is [`CartableOptionPointer`], which is like `Option<Rc>` but
+//! with a niche so that the resulting `Yoke` has a niche. The following four
+//! types can be stored in the `CartableOptionPointer`:
+//!
+//! 1. `&T`
+//! 2. `Box<T>`
+//! 3. `Rc<T>`
+//! 4. `Arc<T>`
+//!
+//! These four types implement the sealed unsafe trait [`CartablePointerLike`].
+//! In addition, all except `Box<T>` impl [`CloneableCartablePointerLike`],
+//! which allows [`CartableOptionPointer`] to implement `Clone`.
+
+use crate::CloneableCart;
+#[cfg(feature = "alloc")]
+use alloc::boxed::Box;
+#[cfg(feature = "alloc")]
+use alloc::rc::Rc;
+#[cfg(feature = "alloc")]
+use alloc::sync::Arc;
+#[cfg(test)]
+use core::cell::Cell;
+use core::marker::PhantomData;
+use core::ptr::NonNull;
+use stable_deref_trait::StableDeref;
+
+// Safety note: this method MUST return the same value for the same T, even if i.e. the method gets
+// instantiated in different crates. This can be untrue in surprising ways! For example, just
+// returning a const-ref-to-const would not guarantee that.
+// The current implementation always returns the same address for any T, see
+// [the reference](https://doc.rust-lang.org/reference/items/static-items.html#statics--generics):
+// there is exactly one `SENTINEL` item for any T.
+#[inline]
+fn sentinel_for<T>() -> NonNull<T> {
+ static SENTINEL: &u8 = &0x1a; // SUB
+
+ // Safety: SENTINEL is indeed not a null pointer, even after the casts.
+ unsafe { NonNull::new_unchecked(SENTINEL as *const u8 as *mut T) }
+}
+
+#[cfg(test)]
+thread_local! {
+ static DROP_INVOCATIONS: Cell<usize> = const { Cell::new(0) };
+}
+
+mod private {
+ pub trait Sealed {}
+}
+
+use private::Sealed;
+
+/// An object fully representable by a non-null pointer.
+///
+/// # Safety
+///
+/// Implementer safety:
+///
+/// 1. `into_raw` transfers ownership of the values referenced by StableDeref to the caller,
+/// if there is ownership to transfer
+/// 2. `drop_raw` returns ownership back to the impl, if there is ownership to transfer
+///
+/// Note: if `into_raw` returns the sentinel pointer, memory leaks may occur, but this will not
+/// lead to undefined behaviour.
+///
+/// Note: the pointer `NonNull<Self::Raw>` may or may not be aligned and it should never
+/// be dereferenced. Rust allows unaligned pointers; see [`std::ptr::read_unaligned`].
+pub unsafe trait CartablePointerLike: StableDeref + Sealed {
+ /// The raw type used for [`Self::into_raw`] and [`Self::drop_raw`].
+ #[doc(hidden)]
+ type Raw;
+
+ /// Converts this pointer-like into a pointer.
+ #[doc(hidden)]
+ fn into_raw(self) -> NonNull<Self::Raw>;
+
+ /// Drops any memory associated with this pointer-like.
+ ///
+ /// # Safety
+ ///
+ /// Caller safety:
+ ///
+ /// 1. The pointer MUST have been returned by this impl's `into_raw`.
+ /// 2. The pointer MUST NOT be dangling.
+ #[doc(hidden)]
+ unsafe fn drop_raw(pointer: NonNull<Self::Raw>);
+}
+
+/// An object that implements [`CartablePointerLike`] that also
+/// supports cloning without changing the address of referenced data.
+///
+/// # Safety
+///
+/// Implementer safety:
+///
+/// 1. `addref_raw` must create a new owner such that an additional call to
+/// `drop_raw` does not create a dangling pointer
+/// 2. `addref_raw` must not change the address of any referenced data.
+pub unsafe trait CloneableCartablePointerLike: CartablePointerLike {
+ /// Clones this pointer-like.
+ ///
+ /// # Safety
+ ///
+ /// Caller safety:
+ ///
+ /// 1. The pointer MUST have been returned by this impl's `into_raw`.
+ /// 2. The pointer MUST NOT be dangling.
+ #[doc(hidden)]
+ unsafe fn addref_raw(pointer: NonNull<Self::Raw>);
+}
+
+impl<'a, T> Sealed for &'a T {}
+
+// Safety:
+// 1. There is no ownership to transfer
+// 2. There is no ownership to transfer
+unsafe impl<'a, T> CartablePointerLike for &'a T {
+ type Raw = T;
+
+ #[inline]
+ fn into_raw(self) -> NonNull<T> {
+ self.into()
+ }
+ #[inline]
+ unsafe fn drop_raw(_pointer: NonNull<T>) {
+ // No-op: references are borrowed from elsewhere
+ }
+}
+
+// Safety:
+// 1. There is no ownership
+// 2. The impl is a no-op so no addresses are changed.
+unsafe impl<'a, T> CloneableCartablePointerLike for &'a T {
+ #[inline]
+ unsafe fn addref_raw(_pointer: NonNull<T>) {
+ // No-op: references are borrowed from elsewhere
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<T> Sealed for Box<T> {}
+
+#[cfg(feature = "alloc")]
+// Safety:
+// 1. `Box::into_raw` says: "After calling this function, the caller is responsible for the
+// memory previously managed by the Box."
+// 2. `Box::from_raw` says: "After calling this function, the raw pointer is owned by the
+// resulting Box."
+unsafe impl<T> CartablePointerLike for Box<T> {
+ type Raw = T;
+
+ #[inline]
+ fn into_raw(self) -> NonNull<T> {
+ // Safety: `Box::into_raw` says: "The pointer will be properly aligned and non-null."
+ unsafe { NonNull::new_unchecked(Box::into_raw(self)) }
+ }
+ #[inline]
+ unsafe fn drop_raw(pointer: NonNull<T>) {
+ // Safety: per the method's precondition, `pointer` is dereferenceable and was returned by
+ // `Self::into_raw`, i.e. by `Box::into_raw`. In this circumstances, calling
+ // `Box::from_raw` is safe.
+ let _box = unsafe { Box::from_raw(pointer.as_ptr()) };
+
+ // Boxes are always dropped
+ #[cfg(test)]
+ DROP_INVOCATIONS.with(|x| x.set(x.get() + 1))
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<T> Sealed for Rc<T> {}
+
+#[cfg(feature = "alloc")]
+// Safety:
+// 1. `Rc::into_raw` says: "Consumes the Rc, returning the wrapped pointer. To avoid a memory
+// leak the pointer must be converted back to an Rc using Rc::from_raw."
+// 2. See 1.
+unsafe impl<T> CartablePointerLike for Rc<T> {
+ type Raw = T;
+
+ #[inline]
+ fn into_raw(self) -> NonNull<T> {
+ // Safety: Rcs must contain data (and not be null)
+ unsafe { NonNull::new_unchecked(Rc::into_raw(self) as *mut T) }
+ }
+
+ #[inline]
+ unsafe fn drop_raw(pointer: NonNull<T>) {
+ // Safety: per the method's precondition, `pointer` is dereferenceable and was returned by
+ // `Self::into_raw`, i.e. by `Rc::into_raw`. In this circumstances, calling
+ // `Rc::from_raw` is safe.
+ let _rc = unsafe { Rc::from_raw(pointer.as_ptr()) };
+
+ // Rc is dropped if refcount is 1
+ #[cfg(test)]
+ if Rc::strong_count(&_rc) == 1 {
+ DROP_INVOCATIONS.with(|x| x.set(x.get() + 1))
+ }
+ }
+}
+
+#[cfg(feature = "alloc")]
+// Safety:
+// 1. The impl increases the refcount such that `Drop` will decrease it.
+// 2. The impl increases refcount without changing the address of data.
+unsafe impl<T> CloneableCartablePointerLike for Rc<T> {
+ #[inline]
+ unsafe fn addref_raw(pointer: NonNull<T>) {
+ // Safety: The caller safety of this function says that:
+ // 1. The pointer was obtained through Rc::into_raw
+ // 2. The associated Rc instance is valid
+ // Further, this impl is not defined for anything but the global allocator.
+ unsafe {
+ Rc::increment_strong_count(pointer.as_ptr());
+ }
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<T> Sealed for Arc<T> {}
+
+#[cfg(feature = "alloc")]
+// Safety:
+// 1. `Rc::into_raw` says: "Consumes the Arc, returning the wrapped pointer. To avoid a memory
+// leak the pointer must be converted back to an Arc using Arc::from_raw."
+// 2. See 1.
+unsafe impl<T> CartablePointerLike for Arc<T> {
+ type Raw = T;
+
+ #[inline]
+ fn into_raw(self) -> NonNull<T> {
+ // Safety: Arcs must contain data (and not be null)
+ unsafe { NonNull::new_unchecked(Arc::into_raw(self) as *mut T) }
+ }
+ #[inline]
+ unsafe fn drop_raw(pointer: NonNull<T>) {
+ // Safety: per the method's precondition, `pointer` is dereferenceable and was returned by
+ // `Self::into_raw`, i.e. by `Rc::into_raw`. In this circumstances, calling
+ // `Rc::from_raw` is safe.
+ let _arc = unsafe { Arc::from_raw(pointer.as_ptr()) };
+
+ // Arc is dropped if refcount is 1
+ #[cfg(test)]
+ if Arc::strong_count(&_arc) == 1 {
+ DROP_INVOCATIONS.with(|x| x.set(x.get() + 1))
+ }
+ }
+}
+
+#[cfg(feature = "alloc")]
+// Safety:
+// 1. The impl increases the refcount such that `Drop` will decrease it.
+// 2. The impl increases refcount without changing the address of data.
+unsafe impl<T> CloneableCartablePointerLike for Arc<T> {
+ #[inline]
+ unsafe fn addref_raw(pointer: NonNull<T>) {
+ // Safety: The caller safety of this function says that:
+ // 1. The pointer was obtained through Arc::into_raw
+ // 2. The associated Arc instance is valid
+ // Further, this impl is not defined for anything but the global allocator.
+ unsafe {
+ Arc::increment_strong_count(pointer.as_ptr());
+ }
+ }
+}
+
+/// A type with similar semantics as `Option<C<T>>` but with a niche.
+///
+/// This type cannot be publicly constructed. To use this in a `Yoke`, see
+/// [`Yoke::convert_cart_into_option_pointer`].
+///
+/// [`Yoke::convert_cart_into_option_pointer`]: crate::Yoke::convert_cart_into_option_pointer
+#[derive(Debug)]
+pub struct CartableOptionPointer<C>
+where
+ C: CartablePointerLike,
+{
+ /// The inner pointer.
+ ///
+ /// # Invariants
+ ///
+ /// 1. Must be either `SENTINEL_PTR` or created from `CartablePointerLike::into_raw`
+ /// 2. If non-sentinel, must _always_ be for a valid SelectedRc
+ inner: NonNull<C::Raw>,
+ _cartable: PhantomData<C>,
+}
+
+impl<C> CartableOptionPointer<C>
+where
+ C: CartablePointerLike,
+{
+ /// Creates a new instance corresponding to a `None` value.
+ #[inline]
+ pub(crate) fn none() -> Self {
+ Self {
+ inner: sentinel_for::<C::Raw>(),
+ _cartable: PhantomData,
+ }
+ }
+
+ /// Creates a new instance corresponding to a `Some` value.
+ #[inline]
+ pub(crate) fn from_cartable(cartable: C) -> Self {
+ let inner = cartable.into_raw();
+ debug_assert_ne!(inner, sentinel_for::<C::Raw>());
+ Self {
+ inner,
+ _cartable: PhantomData,
+ }
+ }
+
+ /// Returns whether this instance is `None`. From the return value:
+ ///
+ /// - If `true`, the instance is `None`
+ /// - If `false`, the instance is a valid `SelectedRc`
+ #[inline]
+ pub fn is_none(&self) -> bool {
+ self.inner == sentinel_for::<C::Raw>()
+ }
+}
+
+impl<C> Drop for CartableOptionPointer<C>
+where
+ C: CartablePointerLike,
+{
+ #[inline]
+ fn drop(&mut self) {
+ let ptr = self.inner;
+ if ptr != sentinel_for::<C::Raw>() {
+ // By the invariants, `ptr` is a valid raw value since it's
+ // either that or sentinel, and we just checked for sentinel.
+ // We will replace it with the sentinel and then drop `ptr`.
+ self.inner = sentinel_for::<C::Raw>();
+ // Safety: by the invariants, `ptr` is a valid raw value.
+ unsafe { C::drop_raw(ptr) }
+ }
+ }
+}
+
+impl<C> Clone for CartableOptionPointer<C>
+where
+ C: CloneableCartablePointerLike,
+{
+ #[inline]
+ fn clone(&self) -> Self {
+ let ptr = self.inner;
+ if ptr != sentinel_for::<C::Raw>() {
+ // By the invariants, `ptr` is a valid raw value since it's
+ // either that or sentinel, and we just checked for sentinel.
+ // Safety: by the invariants, `ptr` is a valid raw value.
+ unsafe { C::addref_raw(ptr) }
+ }
+ Self {
+ inner: self.inner,
+ _cartable: PhantomData,
+ }
+ }
+}
+
+// Safety: logically an Option<C>. Has same bounds as Option<C>.
+// The `StableDeref` parts of `C` continue to be `StableDeref`.
+unsafe impl<C> CloneableCart for CartableOptionPointer<C> where
+ C: CloneableCartablePointerLike + CloneableCart
+{
+}
+
+// Safety: logically an Option<C>. Has same bounds as Option<C>
+unsafe impl<C> Send for CartableOptionPointer<C> where C: Sync + CartablePointerLike {}
+
+// Safety: logically an Option<C>. Has same bounds as Option<C>
+unsafe impl<C> Sync for CartableOptionPointer<C> where C: Send + CartablePointerLike {}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::Yoke;
+ use core::mem::size_of;
+
+ const SAMPLE_BYTES: &[u8] = b"abCDEfg";
+ const W: usize = size_of::<usize>();
+
+ #[test]
+ fn test_sizes() {
+ assert_eq!(W * 4, size_of::<Yoke<[usize; 3], &&[u8]>>());
+ assert_eq!(W * 4, size_of::<Yoke<[usize; 3], Option<&&[u8]>>>());
+ assert_eq!(
+ W * 4,
+ size_of::<Yoke<[usize; 3], CartableOptionPointer<&&[u8]>>>()
+ );
+
+ assert_eq!(W * 4, size_of::<Option<Yoke<[usize; 3], &&[u8]>>>());
+ assert_eq!(W * 5, size_of::<Option<Yoke<[usize; 3], Option<&&[u8]>>>>());
+ assert_eq!(
+ W * 4,
+ size_of::<Option<Yoke<[usize; 3], CartableOptionPointer<&&[u8]>>>>()
+ );
+ }
+
+ #[test]
+ fn test_new_sentinel() {
+ let start = DROP_INVOCATIONS.with(Cell::get);
+ {
+ let _ = CartableOptionPointer::<Rc<&[u8]>>::none();
+ }
+ assert_eq!(start, DROP_INVOCATIONS.with(Cell::get));
+ {
+ let _ = CartableOptionPointer::<Rc<&[u8]>>::none();
+ }
+ assert_eq!(start, DROP_INVOCATIONS.with(Cell::get));
+ }
+
+ #[test]
+ fn test_new_rc() {
+ let start = DROP_INVOCATIONS.with(Cell::get);
+ {
+ let _ = CartableOptionPointer::<Rc<&[u8]>>::from_cartable(SAMPLE_BYTES.into());
+ }
+ assert_eq!(start + 1, DROP_INVOCATIONS.with(Cell::get));
+ }
+
+ #[test]
+ fn test_rc_clone() {
+ let start = DROP_INVOCATIONS.with(Cell::get);
+ {
+ let x = CartableOptionPointer::<Rc<&[u8]>>::from_cartable(SAMPLE_BYTES.into());
+ assert_eq!(start, DROP_INVOCATIONS.with(Cell::get));
+ {
+ let _ = x.clone();
+ }
+ assert_eq!(start, DROP_INVOCATIONS.with(Cell::get));
+ {
+ let _ = x.clone();
+ let _ = x.clone();
+ let _ = x.clone();
+ }
+ assert_eq!(start, DROP_INVOCATIONS.with(Cell::get));
+ }
+ assert_eq!(start + 1, DROP_INVOCATIONS.with(Cell::get));
+ }
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/either.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/either.rs
new file mode 100644
index 0000000..7de6edf
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/either.rs
@@ -0,0 +1,88 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! Types to enable polymorphic carts.
+
+use crate::CloneableCart;
+
+use core::ops::Deref;
+use stable_deref_trait::StableDeref;
+
+/// A cart that can be one type or the other. Enables ergonomic polymorphic carts.
+///
+/// `EitherCart` enables yokes originating from different data sources and therefore
+/// having different cart types to be merged into the same yoke type, but still being
+/// able to recover the original cart type if necessary.
+///
+/// All relevant Cart traits are implemented for `EitherCart`, and carts can be
+/// safely wrapped in an `EitherCart`.
+///
+/// Also see [`Yoke::erase_box_cart()`](crate::Yoke::erase_box_cart).
+///
+/// # Examples
+///
+/// ```
+/// use std::rc::Rc;
+/// use yoke::either::EitherCart;
+/// use yoke::Yoke;
+///
+/// let y1: Yoke<&'static str, Rc<str>> =
+/// Yoke::attach_to_zero_copy_cart("reference counted hello world".into());
+///
+/// let y2: Yoke<&'static str, &str> = Yoke::attach_to_zero_copy_cart("borrowed hello world");
+///
+/// type CombinedYoke<'a> = Yoke<&'static str, EitherCart<Rc<str>, &'a str>>;
+///
+/// // Both yokes can be combined into a single yoke type despite different carts
+/// let y3: CombinedYoke = y1.wrap_cart_in_either_a();
+/// let y4: CombinedYoke = y2.wrap_cart_in_either_b();
+///
+/// assert_eq!(*y3.get(), "reference counted hello world");
+/// assert_eq!(*y4.get(), "borrowed hello world");
+///
+/// // The resulting yoke is cloneable if both cart types implement CloneableCart
+/// let y5 = y4.clone();
+/// assert_eq!(*y5.get(), "borrowed hello world");
+/// ```
+#[derive(Clone, PartialEq, Eq, Debug)]
+#[allow(clippy::exhaustive_enums)] // stable
+pub enum EitherCart<C0, C1> {
+ A(C0),
+ B(C1),
+}
+
+impl<C0, C1, T> Deref for EitherCart<C0, C1>
+where
+ C0: Deref<Target = T>,
+ C1: Deref<Target = T>,
+ T: ?Sized,
+{
+ type Target = T;
+ fn deref(&self) -> &T {
+ use EitherCart::*;
+ match self {
+ A(a) => a.deref(),
+ B(b) => b.deref(),
+ }
+ }
+}
+
+// Safety: Safe because both sub-types implement the trait.
+unsafe impl<C0, C1, T> StableDeref for EitherCart<C0, C1>
+where
+ C0: StableDeref,
+ C1: StableDeref,
+ C0: Deref<Target = T>,
+ C1: Deref<Target = T>,
+ T: ?Sized,
+{
+}
+
+// Safety: Safe because both sub-types implement the trait.
+unsafe impl<C0, C1> CloneableCart for EitherCart<C0, C1>
+where
+ C0: CloneableCart,
+ C1: CloneableCart,
+{
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/erased.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/erased.rs
new file mode 100644
index 0000000..4395404
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/erased.rs
@@ -0,0 +1,41 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! This module contains helper types for erasing Cart types.
+//!
+//! See the docs of [`Yoke::erase_rc_cart()`](crate::Yoke::erase_rc_cart)
+//! and [`Yoke::erase_box_cart()`](crate::Yoke::erase_box_cart) for more info.
+//!
+//! âš *Enabled with the `alloc` Cargo feature.*
+
+use alloc::boxed::Box;
+use alloc::rc::Rc;
+use alloc::sync::Arc;
+
+/// Dummy trait that lets us `dyn Drop`
+///
+/// `dyn Drop` isn't legal (and doesn't make sense since `Drop` is not
+/// implement on all destructible types). However, all trait objects come with
+/// a destructor, so we can just use an empty trait to get a destructor object.
+pub trait ErasedDestructor: 'static {}
+impl<T: 'static> ErasedDestructor for T {}
+
+/// A type-erased Cart that has `Arc` semantics
+///
+/// See the docs of [`Yoke::erase_arc_cart()`](crate::Yoke::erase_rc_cart) for more info.
+///
+/// âš *Enabled with the `alloc` Cargo feature.*
+pub type ErasedArcCart = Arc<dyn ErasedDestructor + Send + Sync>;
+/// A type-erased Cart that has `Rc` semantics
+///
+/// See the docs of [`Yoke::erase_rc_cart()`](crate::Yoke::erase_rc_cart) for more info.
+///
+/// âš *Enabled with the `alloc` Cargo feature.*
+pub type ErasedRcCart = Rc<dyn ErasedDestructor>;
+/// A type-erased Cart that has `Box` semantics
+///
+/// See the docs of [`Yoke::erase_box_cart()`](crate::Yoke::erase_box_cart) for more info.
+///
+/// âš *Enabled with the `alloc` Cargo feature.*
+pub type ErasedBoxCart = Box<dyn ErasedDestructor>;
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/kinda_sorta_dangling.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/kinda_sorta_dangling.rs
new file mode 100644
index 0000000..1f099f7
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/kinda_sorta_dangling.rs
@@ -0,0 +1,95 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use core::mem::{ManuallyDrop, MaybeUninit};
+use core::ops::{Deref, DerefMut};
+
+/// This type is intended to be similar to the type `MaybeDangling<T>`
+/// proposed in [RFC 3336].
+///
+/// The effect of this is that in Rust's safety model, types inside here are not
+/// expected to have any memory dependent validity properties (`dereferenceable`, `noalias`).
+///
+/// See [#3696] for a testcase where `Yoke` fails under miri's field-retagging mode if not using
+/// KindaSortaDangling.
+///
+/// This has `T: 'static` since we don't need anything
+/// else and we don't want to have to think (more) about variance over lifetimes or dropck.
+///
+/// After [RFC 3336] lands we can use `MaybeDangling` instead.
+///
+/// Note that a version of this type also exists publicly as the [`maybe_dangling`]
+/// crate; which also exports a patched `ManuallyDrop` with similar semantics and
+/// does not require `T: 'static`. Consider using this if you need something more general
+/// and are okay with adding dependencies.
+///
+/// [RFC 3336]: https://github.com/rust-lang/rfcs/pull/3336
+/// [#3696]: https://github.com/unicode-org/icu4x/issues/3696
+/// [`maybe_dangling`](https://docs.rs/maybe-dangling/0.1.0/maybe_dangling/struct.MaybeDangling.html)
+#[repr(transparent)]
+pub(crate) struct KindaSortaDangling<T: 'static> {
+ /// Safety invariant: This is always an initialized T, never uninit or other
+ /// invalid bit patterns. Its drop glue will execute during Drop::drop rather than
+ /// during the drop glue for KindaSortaDangling, which means that we have to be careful about
+ /// not touching the values as initialized during `drop` after that, but that's a short period of time.
+ dangle: MaybeUninit<T>,
+}
+
+impl<T: 'static> KindaSortaDangling<T> {
+ #[inline]
+ pub(crate) const fn new(dangle: T) -> Self {
+ KindaSortaDangling {
+ dangle: MaybeUninit::new(dangle),
+ }
+ }
+ #[inline]
+ pub(crate) fn into_inner(self) -> T {
+ // Self has a destructor, we want to avoid having it be called
+ let manual = ManuallyDrop::new(self);
+ // Safety:
+ // We can call assume_init_read() due to the library invariant on this type,
+ // however since it is a read() we must be careful about data duplication.
+ // The only code using `self` after this is the drop glue, which we have disabled via
+ // the ManuallyDrop.
+ unsafe { manual.dangle.assume_init_read() }
+ }
+}
+
+impl<T: 'static> Deref for KindaSortaDangling<T> {
+ type Target = T;
+ #[inline]
+ fn deref(&self) -> &T {
+ // Safety: Due to the safety invariant on `dangle`, it is guaranteed to be always
+ // initialized as deref is never called during drop.
+ unsafe { self.dangle.assume_init_ref() }
+ }
+}
+
+impl<T: 'static> DerefMut for KindaSortaDangling<T> {
+ #[inline]
+ fn deref_mut(&mut self) -> &mut T {
+ // Safety: Due to the safety invariant on `dangle`, it is guaranteed to be always
+ // initialized as deref_mut is never called during drop.
+ unsafe { self.dangle.assume_init_mut() }
+ }
+}
+
+impl<T: 'static> Drop for KindaSortaDangling<T> {
+ #[inline]
+ fn drop(&mut self) {
+ // Safety: We are reading and dropping a valid initialized T.
+ //
+ // As `drop_in_place()` is a `read()`-like duplication operation we must be careful that the original value isn't
+ // used afterwards. It won't be because this is drop and the only
+ // code that will run after this is `self`'s drop glue, and that drop glue is empty
+ // because MaybeUninit has no drop.
+ //
+ // We use `drop_in_place()` instead of `let _ = ... .assume_init_read()` to avoid creating a move
+ // of the inner `T` (without `KindaSortaDangling` protection!) type into a local -- we don't want to
+ // assert any of `T`'s memory-related validity properties here.
+ unsafe {
+ self.dangle.as_mut_ptr().drop_in_place();
+ }
+ }
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/lib.rs
new file mode 100644
index 0000000..f2a7ddb
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/lib.rs
@@ -0,0 +1,67 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! This crate provides [`Yoke<Y, C>`][Yoke], which allows one to "yoke" (attach) a zero-copy deserialized
+//! object (say, a [`Cow<'a, str>`](alloc::borrow::Cow)) to the source it was deserialized from, (say, an [`Rc<[u8]>`](alloc::rc::Rc)),
+//! known in this crate as a "cart", producing a type that looks like `Yoke<Cow<'static, str>, Rc<[u8]>>`
+//! and can be moved around with impunity.
+//!
+//! Succinctly, this allows one to "erase" static lifetimes and turn them into dynamic ones, similarly
+//! to how `dyn` allows one to "erase" static types and turn them into dynamic ones.
+//!
+//! Most of the time the yokeable `Y` type will be some kind of zero-copy deserializable
+//! abstraction, potentially with an owned variant (like [`Cow`](alloc::borrow::Cow),
+//! [`ZeroVec`](https://docs.rs/zerovec), or an aggregate containing such types), and the cart `C` will be some smart pointer like
+//! [`Box<T>`](alloc::boxed::Box), [`Rc<T>`](alloc::rc::Rc), or [`Arc<T>`](std::sync::Arc), potentially wrapped in an [`Option<T>`](Option).
+//!
+//! The key behind this crate is [`Yoke::get()`], where calling [`.get()`][Yoke::get] on a type like
+//! `Yoke<Cow<'static, str>, _>` will get you a short-lived `&'a Cow<'a, str>`, restricted to the
+//! lifetime of the borrow used during [`.get()`](Yoke::get). This is entirely safe since the `Cow` borrows from
+//! the cart type `C`, which cannot be interfered with as long as the `Yoke` is borrowed by [`.get()`](Yoke::get).
+//! [`.get()`](Yoke::get) protects access by essentially reifying the erased lifetime to a safe local one
+//! when necessary.
+//!
+//! See the documentation of [`Yoke`] for more details.
+
+// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
+#![cfg_attr(not(any(test, doc)), no_std)]
+#![cfg_attr(
+ not(test),
+ deny(
+ clippy::indexing_slicing,
+ clippy::unwrap_used,
+ clippy::expect_used,
+ clippy::panic,
+ clippy::exhaustive_structs,
+ clippy::exhaustive_enums,
+ clippy::trivially_copy_pass_by_ref,
+ missing_debug_implementations,
+ )
+)]
+// The lifetimes here are important for safety and explicitly writing
+// them out is good even when redundant
+#![allow(clippy::needless_lifetimes)]
+
+#[cfg(feature = "alloc")]
+extern crate alloc;
+
+pub mod cartable_ptr;
+pub mod either;
+#[cfg(feature = "alloc")]
+pub mod erased;
+mod kinda_sorta_dangling;
+mod macro_impls;
+mod yoke;
+mod yokeable;
+#[cfg(feature = "zerofrom")]
+mod zero_from;
+
+#[cfg(feature = "derive")]
+pub use yoke_derive::Yokeable;
+
+pub use crate::yoke::{CloneableCart, Yoke};
+pub use crate::yokeable::Yokeable;
+
+#[cfg(feature = "zerofrom")]
+use zerofrom::ZeroFrom;
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/macro_impls.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/macro_impls.rs
new file mode 100644
index 0000000..4e17db9
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/macro_impls.rs
@@ -0,0 +1,128 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+// In this case consistency between impls is more important
+// than using pointer casts
+#![allow(clippy::transmute_ptr_to_ptr)]
+
+use crate::Yokeable;
+use core::{
+ mem::{self, ManuallyDrop},
+ ptr,
+};
+
+macro_rules! copy_yoke_impl {
+ () => {
+ #[inline]
+ fn transform(&self) -> &Self::Output {
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> Self::Output {
+ self
+ }
+ #[inline]
+ unsafe fn make(this: Self::Output) -> Self {
+ this
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output),
+ {
+ f(self)
+ }
+ };
+}
+macro_rules! impl_copy_type {
+ ($ty:ty) => {
+ // Safety: all the types that this macro is used to generate impls of Yokeable for do not
+ // borrow any memory.
+ unsafe impl<'a> Yokeable<'a> for $ty {
+ type Output = Self;
+ copy_yoke_impl!();
+ }
+ };
+}
+
+impl_copy_type!(());
+impl_copy_type!(u8);
+impl_copy_type!(u16);
+impl_copy_type!(u32);
+impl_copy_type!(u64);
+impl_copy_type!(u128);
+impl_copy_type!(usize);
+impl_copy_type!(i8);
+impl_copy_type!(i16);
+impl_copy_type!(i32);
+impl_copy_type!(i64);
+impl_copy_type!(i128);
+impl_copy_type!(isize);
+impl_copy_type!(char);
+impl_copy_type!(bool);
+
+// This is for when we're implementing Yoke on a complex type such that it's not
+// obvious to the compiler that the lifetime is covariant
+//
+// Safety: the caller of this macro must ensure that `Self` is indeed covariant in 'a.
+macro_rules! unsafe_complex_yoke_impl {
+ () => {
+ fn transform(&'a self) -> &'a Self::Output {
+ // Safety: equivalent to casting the lifetime. Macro caller ensures covariance.
+ unsafe { mem::transmute(self) }
+ }
+
+ fn transform_owned(self) -> Self::Output {
+ debug_assert!(mem::size_of::<Self::Output>() == mem::size_of::<Self>());
+ // Safety: equivalent to casting the lifetime. Macro caller ensures covariance.
+ unsafe {
+ let ptr: *const Self::Output = (&self as *const Self).cast();
+ let _ = ManuallyDrop::new(self);
+ ptr::read(ptr)
+ }
+ }
+
+ unsafe fn make(from: Self::Output) -> Self {
+ debug_assert!(mem::size_of::<Self::Output>() == mem::size_of::<Self>());
+ let ptr: *const Self = (&from as *const Self::Output).cast();
+ let _ = ManuallyDrop::new(from);
+ // Safety: `ptr` is certainly valid, aligned and points to a properly initialized value, as
+ // it comes from a value that was moved into a ManuallyDrop.
+ unsafe { ptr::read(ptr) }
+ }
+
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output),
+ {
+ // Cast away the lifetime of Self
+ // Safety: this is equivalent to f(transmute(self)), and the documentation of the trait
+ // method explains why doing so is sound.
+ unsafe { f(mem::transmute::<&'a mut Self, &'a mut Self::Output>(self)) }
+ }
+ };
+}
+
+// Safety: since T implements Yokeable<'a>, Option<T<'b>> must be covariant on 'b or the Yokeable
+// implementation on T would be unsound.
+unsafe impl<'a, T: 'static + for<'b> Yokeable<'b>> Yokeable<'a> for Option<T> {
+ type Output = Option<<T as Yokeable<'a>>::Output>;
+ unsafe_complex_yoke_impl!();
+}
+
+// Safety: since T1, T2 implement Yokeable<'a>, (T1<'b>, T2<'b>) must be covariant on 'b or the Yokeable
+// implementation on T would be unsound.
+unsafe impl<'a, T1: 'static + for<'b> Yokeable<'b>, T2: 'static + for<'b> Yokeable<'b>> Yokeable<'a>
+ for (T1, T2)
+{
+ type Output = (<T1 as Yokeable<'a>>::Output, <T2 as Yokeable<'a>>::Output);
+ unsafe_complex_yoke_impl!();
+}
+
+// Safety: since T implements Yokeable<'a>, [T<'b>; N] must be covariant on 'b or the Yokeable
+// implementation on T would be unsound.
+unsafe impl<'a, T: 'static + for<'b> Yokeable<'b>, const N: usize> Yokeable<'a> for [T; N] {
+ type Output = [<T as Yokeable<'a>>::Output; N];
+ unsafe_complex_yoke_impl!();
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yoke.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yoke.rs
new file mode 100644
index 0000000..db564df1
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yoke.rs
@@ -0,0 +1,1540 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::cartable_ptr::{CartableOptionPointer, CartablePointerLike};
+use crate::either::EitherCart;
+#[cfg(feature = "alloc")]
+use crate::erased::{ErasedArcCart, ErasedBoxCart, ErasedRcCart};
+use crate::kinda_sorta_dangling::KindaSortaDangling;
+use crate::Yokeable;
+use core::marker::PhantomData;
+use core::ops::Deref;
+use stable_deref_trait::StableDeref;
+
+#[cfg(feature = "alloc")]
+use alloc::boxed::Box;
+#[cfg(feature = "alloc")]
+use alloc::rc::Rc;
+#[cfg(feature = "alloc")]
+use alloc::sync::Arc;
+
+/// A Cow-like borrowed object "yoked" to its backing data.
+///
+/// This allows things like zero copy deserialized data to carry around
+/// shared references to their backing buffer, by "erasing" their static lifetime
+/// and turning it into a dynamically managed one.
+///
+/// `Y` (the [`Yokeable`]) is the object containing the references,
+/// and will typically be of the form `Foo<'static>`. The `'static` is
+/// not the actual lifetime of the data, rather it is a convenient way to mark the
+/// erased lifetime and make it dynamic.
+///
+/// `C` is the "cart", which `Y` may contain references to. After the yoke is constructed,
+/// the cart serves little purpose except to guarantee that `Y`'s references remain valid
+/// for as long as the yoke remains in memory (by calling the destructor at the appropriate moment).
+///
+/// The primary constructor for [`Yoke`] is [`Yoke::attach_to_cart()`]. Several variants of that
+/// constructor are provided to serve numerous types of call sites and `Yoke` signatures.
+///
+/// The key behind this type is [`Yoke::get()`], where calling [`.get()`][Yoke::get] on a type like
+/// `Yoke<Cow<'static, str>, _>` will get you a short-lived `&'a Cow<'a, str>`, restricted to the
+/// lifetime of the borrow used during `.get()`. This is entirely safe since the `Cow` borrows from
+/// the cart type `C`, which cannot be interfered with as long as the `Yoke` is borrowed by `.get
+/// ()`. `.get()` protects access by essentially reifying the erased lifetime to a safe local one
+/// when necessary.
+///
+/// Furthermore, there are various [`.map_project()`][Yoke::map_project] methods that allow turning a `Yoke`
+/// into another `Yoke` containing a different type that may contain elements of the original yoked
+/// value. See the [`Yoke::map_project()`] docs for more details.
+///
+/// In general, `C` is a concrete type, but it is also possible for it to be a trait object.
+///
+/// # Example
+///
+/// For example, we can use this to store zero-copy deserialized data in a cache:
+///
+/// ```rust
+/// # use yoke::Yoke;
+/// # use std::rc::Rc;
+/// # use std::borrow::Cow;
+/// # fn load_from_cache(_filename: &str) -> Rc<[u8]> {
+/// # // dummy implementation
+/// # Rc::new([0x5, 0, 0, 0, 0, 0, 0, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f])
+/// # }
+///
+/// fn load_object(filename: &str) -> Yoke<Cow<'static, str>, Rc<[u8]>> {
+/// let rc: Rc<[u8]> = load_from_cache(filename);
+/// Yoke::<Cow<'static, str>, Rc<[u8]>>::attach_to_cart(rc, |data: &[u8]| {
+/// // essentially forcing a #[serde(borrow)]
+/// Cow::Borrowed(bincode::deserialize(data).unwrap())
+/// })
+/// }
+///
+/// let yoke = load_object("filename.bincode");
+/// assert_eq!(&**yoke.get(), "hello");
+/// assert!(matches!(yoke.get(), &Cow::Borrowed(_)));
+/// ```
+pub struct Yoke<Y: for<'a> Yokeable<'a>, C> {
+ // must be the first field for drop order
+ // this will have a 'static lifetime parameter, that parameter is a lie
+ yokeable: KindaSortaDangling<Y>,
+ // Safety invariant: this type can be anything, but `yokeable` may only contain references to
+ // StableDeref parts of this cart, and the targets of those references must be valid for the
+ // lifetime of this cart (it must own or borrow them). It's ok for this cart to contain stack
+ // data as long as it is not referenced by `yokeable` during construction. `attach_to_cart`,
+ // the typical constructor of this type, upholds this invariant, but other constructors like
+ // `replace_cart` need to uphold it.
+ // The implementation guarantees that there are no live `yokeable`s that reference data
+ // in a `cart` when the `cart` is dropped; this is guaranteed in the drop glue through field
+ // order.
+ cart: C,
+}
+
+// Manual `Debug` implementation, since the derived one would be unsound.
+// See https://github.com/unicode-org/icu4x/issues/3685
+impl<Y: for<'a> Yokeable<'a>, C: core::fmt::Debug> core::fmt::Debug for Yoke<Y, C>
+where
+ for<'a> <Y as Yokeable<'a>>::Output: core::fmt::Debug,
+{
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ f.debug_struct("Yoke")
+ .field("yokeable", self.get())
+ .field("cart", self.backing_cart())
+ .finish()
+ }
+}
+
+#[test]
+fn test_debug() {
+ let local_data = "foo".to_owned();
+ let y1 = Yoke::<alloc::borrow::Cow<'static, str>, Rc<String>>::attach_to_zero_copy_cart(
+ Rc::new(local_data),
+ );
+ assert_eq!(
+ format!("{y1:?}"),
+ r#"Yoke { yokeable: "foo", cart: "foo" }"#,
+ );
+}
+
+impl<Y: for<'a> Yokeable<'a>, C: StableDeref> Yoke<Y, C>
+where
+ <C as Deref>::Target: 'static,
+{
+ /// Construct a [`Yoke`] by yokeing an object to a cart in a closure.
+ ///
+ /// The closure can read and write data outside of its scope, but data it returns
+ /// may borrow only from the argument passed to the closure.
+ ///
+ /// See also [`Yoke::try_attach_to_cart()`] to return a `Result` from the closure.
+ ///
+ /// Call sites for this function may not compile pre-1.61; if this still happens, use
+ /// [`Yoke::attach_to_cart_badly()`] and file a bug.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use yoke::Yoke;
+ /// # use std::rc::Rc;
+ /// # use std::borrow::Cow;
+ /// # fn load_from_cache(_filename: &str) -> Rc<[u8]> {
+ /// # // dummy implementation
+ /// # Rc::new([0x5, 0, 0, 0, 0, 0, 0, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f])
+ /// # }
+ ///
+ /// fn load_object(filename: &str) -> Yoke<Cow<'static, str>, Rc<[u8]>> {
+ /// let rc: Rc<[u8]> = load_from_cache(filename);
+ /// Yoke::<Cow<'static, str>, Rc<[u8]>>::attach_to_cart(rc, |data: &[u8]| {
+ /// // essentially forcing a #[serde(borrow)]
+ /// Cow::Borrowed(bincode::deserialize(data).unwrap())
+ /// })
+ /// }
+ ///
+ /// let yoke: Yoke<Cow<str>, _> = load_object("filename.bincode");
+ /// assert_eq!(&**yoke.get(), "hello");
+ /// assert!(matches!(yoke.get(), &Cow::Borrowed(_)));
+ /// ```
+ ///
+ /// Write the number of consumed bytes to a local variable:
+ ///
+ /// ```
+ /// # use yoke::Yoke;
+ /// # use std::rc::Rc;
+ /// # use std::borrow::Cow;
+ /// # fn load_from_cache(_filename: &str) -> Rc<[u8]> {
+ /// # // dummy implementation
+ /// # Rc::new([0x5, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0, 0, 0])
+ /// # }
+ ///
+ /// fn load_object(
+ /// filename: &str,
+ /// ) -> (Yoke<Cow<'static, str>, Rc<[u8]>>, usize) {
+ /// let rc: Rc<[u8]> = load_from_cache(filename);
+ /// let mut bytes_remaining = 0;
+ /// let bytes_remaining = &mut bytes_remaining;
+ /// let yoke = Yoke::<Cow<'static, str>, Rc<[u8]>>::attach_to_cart(
+ /// rc,
+ /// |data: &[u8]| {
+ /// let mut d = postcard::Deserializer::from_bytes(data);
+ /// let output = serde::Deserialize::deserialize(&mut d);
+ /// *bytes_remaining = d.finalize().unwrap().len();
+ /// Cow::Borrowed(output.unwrap())
+ /// },
+ /// );
+ /// (yoke, *bytes_remaining)
+ /// }
+ ///
+ /// let (yoke, bytes_remaining) = load_object("filename.postcard");
+ /// assert_eq!(&**yoke.get(), "hello");
+ /// assert!(matches!(yoke.get(), &Cow::Borrowed(_)));
+ /// assert_eq!(bytes_remaining, 3);
+ /// ```
+ pub fn attach_to_cart<F>(cart: C, f: F) -> Self
+ where
+ // safety note: This works by enforcing that the *only* place the return value of F
+ // can borrow from is the cart, since `F` must be valid for all lifetimes `'de`
+ //
+ // The <C as Deref>::Target: 'static on the impl is crucial for safety as well
+ //
+ // See safety docs at the bottom of this file for more information
+ F: for<'de> FnOnce(&'de <C as Deref>::Target) -> <Y as Yokeable<'de>>::Output,
+ <C as Deref>::Target: 'static,
+ {
+ let deserialized = f(cart.deref());
+ Self {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs at the bottom of this file
+ // for the justification of why yokeable could only borrow from the Cart.
+ unsafe { Y::make(deserialized) },
+ ),
+ cart,
+ }
+ }
+
+ /// Construct a [`Yoke`] by yokeing an object to a cart. If an error occurs in the
+ /// deserializer function, the error is passed up to the caller.
+ ///
+ /// Call sites for this function may not compile pre-1.61; if this still happens, use
+ /// [`Yoke::try_attach_to_cart_badly()`] and file a bug.
+ pub fn try_attach_to_cart<E, F>(cart: C, f: F) -> Result<Self, E>
+ where
+ F: for<'de> FnOnce(&'de <C as Deref>::Target) -> Result<<Y as Yokeable<'de>>::Output, E>,
+ <C as Deref>::Target: 'static,
+ {
+ let deserialized = f(cart.deref())?;
+ Ok(Self {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs at the bottom of this file
+ // for the justification of why yokeable could only borrow from the Cart.
+ unsafe { Y::make(deserialized) },
+ ),
+ cart,
+ })
+ }
+
+ /// Use [`Yoke::attach_to_cart()`].
+ ///
+ /// This was needed because the pre-1.61 compiler couldn't always handle the FnOnce trait bound.
+ #[deprecated]
+ pub fn attach_to_cart_badly(
+ cart: C,
+ f: for<'de> fn(&'de <C as Deref>::Target) -> <Y as Yokeable<'de>>::Output,
+ ) -> Self {
+ Self::attach_to_cart(cart, f)
+ }
+
+ /// Use [`Yoke::try_attach_to_cart()`].
+ ///
+ /// This was needed because the pre-1.61 compiler couldn't always handle the FnOnce trait bound.
+ #[deprecated]
+ pub fn try_attach_to_cart_badly<E>(
+ cart: C,
+ f: for<'de> fn(&'de <C as Deref>::Target) -> Result<<Y as Yokeable<'de>>::Output, E>,
+ ) -> Result<Self, E> {
+ Self::try_attach_to_cart(cart, f)
+ }
+}
+
+impl<Y: for<'a> Yokeable<'a>, C> Yoke<Y, C> {
+ /// Obtain a valid reference to the yokeable data
+ ///
+ /// This essentially transforms the lifetime of the internal yokeable data to
+ /// be valid.
+ /// For example, if you're working with a `Yoke<Cow<'static, T>, C>`, this
+ /// will return an `&'a Cow<'a, T>`
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// # use yoke::Yoke;
+ /// # use std::rc::Rc;
+ /// # use std::borrow::Cow;
+ /// # fn load_from_cache(_filename: &str) -> Rc<[u8]> {
+ /// # // dummy implementation
+ /// # Rc::new([0x5, 0, 0, 0, 0, 0, 0, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f])
+ /// # }
+ /// #
+ /// # fn load_object(filename: &str) -> Yoke<Cow<'static, str>, Rc<[u8]>> {
+ /// # let rc: Rc<[u8]> = load_from_cache(filename);
+ /// # Yoke::<Cow<'static, str>, Rc<[u8]>>::attach_to_cart(rc, |data: &[u8]| {
+ /// # Cow::Borrowed(bincode::deserialize(data).unwrap())
+ /// # })
+ /// # }
+ ///
+ /// // load_object() defined in the example at the top of this page
+ /// let yoke: Yoke<Cow<str>, _> = load_object("filename.bincode");
+ /// assert_eq!(yoke.get(), "hello");
+ /// ```
+ #[inline]
+ pub fn get<'a>(&'a self) -> &'a <Y as Yokeable<'a>>::Output {
+ self.yokeable.transform()
+ }
+
+ /// Get a reference to the backing cart.
+ ///
+ /// This can be useful when building caches, etc. However, if you plan to store the cart
+ /// separately from the yoke, read the note of caution below in [`Yoke::into_backing_cart`].
+ pub fn backing_cart(&self) -> &C {
+ &self.cart
+ }
+
+ /// Get the backing cart by value, dropping the yokeable object.
+ ///
+ /// **Caution:** Calling this method could cause information saved in the yokeable object but
+ /// not the cart to be lost. Use this method only if the yokeable object cannot contain its
+ /// own information.
+ ///
+ /// # Example
+ ///
+ /// Good example: the yokeable object is only a reference, so no information can be lost.
+ ///
+ /// ```
+ /// use yoke::Yoke;
+ ///
+ /// let local_data = "foo".to_owned();
+ /// let yoke = Yoke::<&'static str, Box<String>>::attach_to_zero_copy_cart(
+ /// Box::new(local_data),
+ /// );
+ /// assert_eq!(*yoke.get(), "foo");
+ ///
+ /// // Get back the cart
+ /// let cart = yoke.into_backing_cart();
+ /// assert_eq!(&*cart, "foo");
+ /// ```
+ ///
+ /// Bad example: information specified in `.with_mut()` is lost.
+ ///
+ /// ```
+ /// use std::borrow::Cow;
+ /// use yoke::Yoke;
+ ///
+ /// let local_data = "foo".to_owned();
+ /// let mut yoke =
+ /// Yoke::<Cow<'static, str>, Box<String>>::attach_to_zero_copy_cart(
+ /// Box::new(local_data),
+ /// );
+ /// assert_eq!(yoke.get(), "foo");
+ ///
+ /// // Override data in the cart
+ /// yoke.with_mut(|cow| {
+ /// let mut_str = cow.to_mut();
+ /// mut_str.clear();
+ /// mut_str.push_str("bar");
+ /// });
+ /// assert_eq!(yoke.get(), "bar");
+ ///
+ /// // Get back the cart
+ /// let cart = yoke.into_backing_cart();
+ /// assert_eq!(&*cart, "foo"); // WHOOPS!
+ /// ```
+ pub fn into_backing_cart(self) -> C {
+ self.cart
+ }
+
+ /// Unsafe function for replacing the cart with another
+ ///
+ /// This can be used for type-erasing the cart, for example.
+ ///
+ /// # Safety
+ ///
+ /// - `f()` must not panic
+ /// - References from the yokeable `Y` should still be valid for the lifetime of the
+ /// returned cart type `C`.
+ ///
+ /// For the purpose of determining this, `Yoke` guarantees that references from the Yokeable
+ /// `Y` into the cart `C` will never be references into its stack data, only heap data protected
+ /// by `StableDeref`. This does not necessarily mean that `C` implements `StableDeref`, rather that
+ /// any data referenced by `Y` must be accessed through a `StableDeref` impl on something `C` owns.
+ ///
+ /// Concretely, this means that if `C = Option<Rc<T>>`, `Y` may contain references to the `T` but not
+ /// anything else.
+ /// - Lifetimes inside C must not be lengthened, even if they are themselves contravariant.
+ /// I.e., if C contains an `fn(&'a u8)`, it cannot be replaced with `fn(&'static u8),
+ /// even though that is typically safe.
+ ///
+ /// Typically, this means implementing `f` as something which _wraps_ the inner cart type `C`.
+ /// `Yoke` only really cares about destructors for its carts so it's fine to erase other
+ /// information about the cart, as long as the backing data will still be destroyed at the
+ /// same time.
+ #[inline]
+ pub unsafe fn replace_cart<C2>(self, f: impl FnOnce(C) -> C2) -> Yoke<Y, C2> {
+ Yoke {
+ // Safety note: the safety invariant of this function guarantees that
+ // the data that the yokeable references has its ownership (if any)
+ // transferred to the new cart before self.cart is dropped.
+ yokeable: self.yokeable,
+ cart: f(self.cart),
+ }
+ }
+
+ /// Mutate the stored [`Yokeable`] data.
+ ///
+ /// See [`Yokeable::transform_mut()`] for why this operation is safe.
+ ///
+ /// # Example
+ ///
+ /// This can be used to partially mutate the stored data, provided
+ /// no _new_ borrowed data is introduced.
+ ///
+ /// ```rust
+ /// # use yoke::{Yoke, Yokeable};
+ /// # use std::rc::Rc;
+ /// # use std::borrow::Cow;
+ /// # use std::mem;
+ /// # fn load_from_cache(_filename: &str) -> Rc<[u8]> {
+ /// # // dummy implementation
+ /// # Rc::new([0x5, 0, 0, 0, 0, 0, 0, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f])
+ /// # }
+ /// #
+ /// # fn load_object(filename: &str) -> Yoke<Bar<'static>, Rc<[u8]>> {
+ /// # let rc: Rc<[u8]> = load_from_cache(filename);
+ /// # Yoke::<Bar<'static>, Rc<[u8]>>::attach_to_cart(rc, |data: &[u8]| {
+ /// # // A real implementation would properly deserialize `Bar` as a whole
+ /// # Bar {
+ /// # numbers: Cow::Borrowed(bincode::deserialize(data).unwrap()),
+ /// # string: Cow::Borrowed(bincode::deserialize(data).unwrap()),
+ /// # owned: Vec::new(),
+ /// # }
+ /// # })
+ /// # }
+ ///
+ /// // also implements Yokeable
+ /// struct Bar<'a> {
+ /// numbers: Cow<'a, [u8]>,
+ /// string: Cow<'a, str>,
+ /// owned: Vec<u8>,
+ /// }
+ ///
+ /// // `load_object()` deserializes an object from a file
+ /// let mut bar: Yoke<Bar, _> = load_object("filename.bincode");
+ /// assert_eq!(bar.get().string, "hello");
+ /// assert!(matches!(bar.get().string, Cow::Borrowed(_)));
+ /// assert_eq!(&*bar.get().numbers, &[0x68, 0x65, 0x6c, 0x6c, 0x6f]);
+ /// assert!(matches!(bar.get().numbers, Cow::Borrowed(_)));
+ /// assert_eq!(&*bar.get().owned, &[]);
+ ///
+ /// bar.with_mut(|bar| {
+ /// bar.string.to_mut().push_str(" world");
+ /// bar.owned.extend_from_slice(&[1, 4, 1, 5, 9]);
+ /// });
+ ///
+ /// assert_eq!(bar.get().string, "hello world");
+ /// assert!(matches!(bar.get().string, Cow::Owned(_)));
+ /// assert_eq!(&*bar.get().owned, &[1, 4, 1, 5, 9]);
+ /// // Unchanged and still Cow::Borrowed
+ /// assert_eq!(&*bar.get().numbers, &[0x68, 0x65, 0x6c, 0x6c, 0x6f]);
+ /// assert!(matches!(bar.get().numbers, Cow::Borrowed(_)));
+ ///
+ /// # unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+ /// # type Output = Bar<'a>;
+ /// # fn transform(&'a self) -> &'a Bar<'a> {
+ /// # self
+ /// # }
+ /// #
+ /// # fn transform_owned(self) -> Bar<'a> {
+ /// # // covariant lifetime cast, can be done safely
+ /// # self
+ /// # }
+ /// #
+ /// # unsafe fn make(from: Bar<'a>) -> Self {
+ /// # let ret = mem::transmute_copy(&from);
+ /// # mem::forget(from);
+ /// # ret
+ /// # }
+ /// #
+ /// # fn transform_mut<F>(&'a mut self, f: F)
+ /// # where
+ /// # F: 'static + FnOnce(&'a mut Self::Output),
+ /// # {
+ /// # unsafe { f(mem::transmute(self)) }
+ /// # }
+ /// # }
+ /// ```
+ pub fn with_mut<'a, F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut <Y as Yokeable<'a>>::Output),
+ {
+ self.yokeable.transform_mut(f)
+ }
+
+ /// Helper function allowing one to wrap the cart type `C` in an `Option<T>`.
+ #[inline]
+ pub fn wrap_cart_in_option(self) -> Yoke<Y, Option<C>> {
+ // Safety: the cart is preserved (since it is just wrapped into a Some),
+ // so any data it owns is too.
+ unsafe { self.replace_cart(Some) }
+ }
+}
+
+impl<Y: for<'a> Yokeable<'a>> Yoke<Y, ()> {
+ /// Construct a new [`Yoke`] from static data. There will be no
+ /// references to `cart` here since [`Yokeable`]s are `'static`,
+ /// this is good for e.g. constructing fully owned
+ /// [`Yoke`]s with no internal borrowing.
+ ///
+ /// This is similar to [`Yoke::new_owned()`] but it does not allow you to
+ /// mix the [`Yoke`] with borrowed data. This is primarily useful
+ /// for using [`Yoke`] in generic scenarios.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// # use yoke::Yoke;
+ /// # use std::borrow::Cow;
+ ///
+ /// let owned: Cow<str> = "hello".to_owned().into();
+ /// // this yoke can be intermingled with actually-borrowed Yokes
+ /// let yoke: Yoke<Cow<str>, ()> = Yoke::new_always_owned(owned);
+ ///
+ /// assert_eq!(yoke.get(), "hello");
+ /// ```
+ pub fn new_always_owned(yokeable: Y) -> Self {
+ Self {
+ // Safety note: this `yokeable` certainly does not reference data owned by (), so we do
+ // not have to worry about when the `yokeable` is dropped.
+ yokeable: KindaSortaDangling::new(yokeable),
+ cart: (),
+ }
+ }
+
+ /// Obtain the yokeable out of a `Yoke<Y, ()>`
+ ///
+ /// For most `Yoke` types this would be unsafe but it's
+ /// fine for `Yoke<Y, ()>` since there are no actual internal
+ /// references
+ pub fn into_yokeable(self) -> Y {
+ // Safety note: since `yokeable` cannot reference data owned by `()`, this is certainly
+ // safe.
+ self.yokeable.into_inner()
+ }
+}
+
+// C does not need to be StableDeref here, if the yoke was constructed it's valid,
+// and new_owned() doesn't construct a yokeable that uses references,
+impl<Y: for<'a> Yokeable<'a>, C> Yoke<Y, Option<C>> {
+ /// Construct a new [`Yoke`] from static data. There will be no
+ /// references to `cart` here since [`Yokeable`]s are `'static`,
+ /// this is good for e.g. constructing fully owned
+ /// [`Yoke`]s with no internal borrowing.
+ ///
+ /// This can be paired with [`Yoke:: wrap_cart_in_option()`] to mix owned
+ /// and borrowed data.
+ ///
+ /// If you do not wish to pair this with borrowed data, [`Yoke::new_always_owned()`] can
+ /// be used to get a [`Yoke`] API on always-owned data.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// # use yoke::Yoke;
+ /// # use std::borrow::Cow;
+ /// # use std::rc::Rc;
+ ///
+ /// let owned: Cow<str> = "hello".to_owned().into();
+ /// // this yoke can be intermingled with actually-borrowed Yokes
+ /// let yoke: Yoke<Cow<str>, Option<Rc<[u8]>>> = Yoke::new_owned(owned);
+ ///
+ /// assert_eq!(yoke.get(), "hello");
+ /// ```
+ pub const fn new_owned(yokeable: Y) -> Self {
+ Self {
+ // Safety note: this `yokeable` is known not to borrow from the cart.
+ yokeable: KindaSortaDangling::new(yokeable),
+ cart: None,
+ }
+ }
+
+ /// Obtain the yokeable out of a `Yoke<Y, Option<C>>` if possible.
+ ///
+ /// If the cart is `None`, this returns `Ok`, but if the cart is `Some`,
+ /// this returns `self` as an error.
+ pub fn try_into_yokeable(self) -> Result<Y, Self> {
+ // Safety: if the cart is None there is no way for the yokeable to
+ // have references into it because of the cart invariant.
+ match self.cart {
+ Some(_) => Err(self),
+ None => Ok(self.yokeable.into_inner()),
+ }
+ }
+}
+
+impl<Y: for<'a> Yokeable<'a>, C: CartablePointerLike> Yoke<Y, Option<C>> {
+ /// Converts a `Yoke<Y, Option<C>>` to `Yoke<Y, CartableOptionPointer<C>>`
+ /// for better niche optimization when stored as a field.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::borrow::Cow;
+ /// use yoke::Yoke;
+ ///
+ /// let yoke: Yoke<Cow<[u8]>, Box<Vec<u8>>> =
+ /// Yoke::attach_to_cart(vec![10, 20, 30].into(), |c| c.into());
+ ///
+ /// let yoke_option = yoke.wrap_cart_in_option();
+ /// let yoke_option_pointer = yoke_option.convert_cart_into_option_pointer();
+ /// ```
+ ///
+ /// The niche improves stack sizes:
+ ///
+ /// ```
+ /// use yoke::Yoke;
+ /// use yoke::cartable_ptr::CartableOptionPointer;
+ /// use std::mem::size_of;
+ /// use std::rc::Rc;
+ ///
+ /// // The data struct is 6 words:
+ /// # #[derive(yoke::Yokeable)]
+ /// # struct MyDataStruct<'a> {
+ /// # _s: (usize, usize, usize, usize),
+ /// # _p: &'a str,
+ /// # }
+ /// const W: usize = core::mem::size_of::<usize>();
+ /// assert_eq!(W * 6, size_of::<MyDataStruct>());
+ ///
+ /// // An enum containing the data struct with an `Option<Rc>` cart is 8 words:
+ /// enum StaticOrYoke1 {
+ /// Static(&'static MyDataStruct<'static>),
+ /// Yoke(Yoke<MyDataStruct<'static>, Option<Rc<String>>>),
+ /// }
+ /// assert_eq!(W * 8, size_of::<StaticOrYoke1>());
+ ///
+ /// // When using `CartableOptionPointer``, we need only 7 words for the same behavior:
+ /// enum StaticOrYoke2 {
+ /// Static(&'static MyDataStruct<'static>),
+ /// Yoke(Yoke<MyDataStruct<'static>, CartableOptionPointer<Rc<String>>>),
+ /// }
+ /// assert_eq!(W * 7, size_of::<StaticOrYoke2>());
+ /// ```
+ #[inline]
+ pub fn convert_cart_into_option_pointer(self) -> Yoke<Y, CartableOptionPointer<C>> {
+ match self.cart {
+ Some(cart) => Yoke {
+ // Safety note: CartableOptionPointer::from_cartable only wraps the `cart`,
+ // so the data referenced by the yokeable is still live.
+ yokeable: self.yokeable,
+ cart: CartableOptionPointer::from_cartable(cart),
+ },
+ None => Yoke {
+ // Safety note: this Yokeable cannot refer to any data since self.cart is None.
+ yokeable: self.yokeable,
+ cart: CartableOptionPointer::none(),
+ },
+ }
+ }
+}
+
+impl<Y: for<'a> Yokeable<'a>, C: CartablePointerLike> Yoke<Y, CartableOptionPointer<C>> {
+ /// Obtain the yokeable out of a `Yoke<Y, CartableOptionPointer<C>>` if possible.
+ ///
+ /// If the cart is `None`, this returns `Ok`, but if the cart is `Some`,
+ /// this returns `self` as an error.
+ #[inline]
+ pub fn try_into_yokeable(self) -> Result<Y, Self> {
+ if self.cart.is_none() {
+ Ok(self.yokeable.into_inner())
+ } else {
+ Err(self)
+ }
+ }
+}
+
+/// This trait marks cart types that do not change source on cloning
+///
+/// This is conceptually similar to [`stable_deref_trait::CloneStableDeref`],
+/// however [`stable_deref_trait::CloneStableDeref`] is not (and should not) be
+/// implemented on [`Option`] (since it's not [`Deref`]). [`CloneableCart`] essentially is
+/// "if there _is_ data to borrow from here, cloning the cart gives you an additional
+/// handle to the same data".
+///
+/// # Safety
+/// This trait is safe to implement on `StableDeref` types which, once `Clone`d, point to the same underlying data and retain ownership.
+///
+/// This trait can also be implemented on aggregates of such types like `Option<T: CloneableCart>` and `(T: CloneableCart, U: CloneableCart)`.
+///
+/// Essentially, all data that could be referenced by a Yokeable (i.e. data that is referenced via a StableDeref) must retain the same
+/// pointer and ownership semantics once cloned.
+pub unsafe trait CloneableCart: Clone {}
+
+#[cfg(feature = "alloc")]
+// Safety: Rc<T> implements CloneStableDeref.
+unsafe impl<T: ?Sized> CloneableCart for Rc<T> {}
+#[cfg(feature = "alloc")]
+// Safety: Arc<T> implements CloneStableDeref.
+unsafe impl<T: ?Sized> CloneableCart for Arc<T> {}
+// Safety: Option<T> cannot deref to anything that T doesn't already deref to.
+unsafe impl<T: CloneableCart> CloneableCart for Option<T> {}
+// Safety: &'a T is indeed StableDeref, and cloning it refers to the same data.
+// &'a T does not own in the first place, so ownership is preserved.
+unsafe impl<'a, T: ?Sized> CloneableCart for &'a T {}
+// Safety: () cannot deref to anything.
+unsafe impl CloneableCart for () {}
+
+/// Clone requires that the cart type `C` derefs to the same address after it is cloned. This works for
+/// Rc, Arc, and &'a T.
+///
+/// For other cart types, clone `.backing_cart()` and re-use `.attach_to_cart()`; however, doing
+/// so may lose mutations performed via `.with_mut()`.
+///
+/// Cloning a `Yoke` is often a cheap operation requiring no heap allocations, in much the same
+/// way that cloning an `Rc` is a cheap operation. However, if the `yokeable` contains owned data
+/// (e.g., from `.with_mut()`), that data will need to be cloned.
+impl<Y: for<'a> Yokeable<'a>, C: CloneableCart> Clone for Yoke<Y, C>
+where
+ for<'a> <Y as Yokeable<'a>>::Output: Clone,
+{
+ fn clone(&self) -> Self {
+ // We have an &T not a T, and we can clone T
+ let this = self.get().clone();
+ Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: C being a CloneableCart guarantees that the data referenced by the
+ // `yokeable` is kept alive by the clone of the cart.
+ unsafe { Y::make(this) },
+ ),
+ cart: self.cart.clone(),
+ }
+ }
+}
+
+#[test]
+fn test_clone() {
+ let local_data = "foo".to_owned();
+ let y1 = Yoke::<alloc::borrow::Cow<'static, str>, Rc<String>>::attach_to_zero_copy_cart(
+ Rc::new(local_data),
+ );
+
+ // Test basic clone
+ let y2 = y1.clone();
+ assert_eq!(y1.get(), "foo");
+ assert_eq!(y2.get(), "foo");
+
+ // Test clone with mutation on target
+ let mut y3 = y1.clone();
+ y3.with_mut(|y| {
+ y.to_mut().push_str("bar");
+ });
+ assert_eq!(y1.get(), "foo");
+ assert_eq!(y2.get(), "foo");
+ assert_eq!(y3.get(), "foobar");
+
+ // Test that mutations on source do not affect target
+ let y4 = y3.clone();
+ y3.with_mut(|y| {
+ y.to_mut().push_str("baz");
+ });
+ assert_eq!(y1.get(), "foo");
+ assert_eq!(y2.get(), "foo");
+ assert_eq!(y3.get(), "foobarbaz");
+ assert_eq!(y4.get(), "foobar");
+}
+
+impl<Y: for<'a> Yokeable<'a>, C> Yoke<Y, C> {
+ /// Allows one to "project" a yoke to perform a transformation on the data, potentially
+ /// looking at a subfield, and producing a new yoke. This will move cart, and the provided
+ /// transformation is only allowed to use data known to be borrowed from the cart.
+ ///
+ /// The callback takes an additional `PhantomData<&()>` parameter to anchor lifetimes
+ /// (see [#86702](https://github.com/rust-lang/rust/issues/86702)) This parameter
+ /// should just be ignored in the callback.
+ ///
+ /// This can be used, for example, to transform data from one format to another:
+ ///
+ /// ```
+ /// # use std::rc::Rc;
+ /// # use yoke::Yoke;
+ /// #
+ /// fn slice(y: Yoke<&'static str, Rc<[u8]>>) -> Yoke<&'static [u8], Rc<[u8]>> {
+ /// y.map_project(move |yk, _| yk.as_bytes())
+ /// }
+ /// ```
+ ///
+ /// This can also be used to create a yoke for a subfield
+ ///
+ /// ```
+ /// # use yoke::{Yoke, Yokeable};
+ /// # use std::mem;
+ /// # use std::rc::Rc;
+ /// #
+ /// // also safely implements Yokeable<'a>
+ /// struct Bar<'a> {
+ /// string_1: &'a str,
+ /// string_2: &'a str,
+ /// }
+ ///
+ /// fn map_project_string_1(
+ /// bar: Yoke<Bar<'static>, Rc<[u8]>>,
+ /// ) -> Yoke<&'static str, Rc<[u8]>> {
+ /// bar.map_project(|bar, _| bar.string_1)
+ /// }
+ ///
+ /// #
+ /// # unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+ /// # type Output = Bar<'a>;
+ /// # fn transform(&'a self) -> &'a Bar<'a> {
+ /// # self
+ /// # }
+ /// #
+ /// # fn transform_owned(self) -> Bar<'a> {
+ /// # // covariant lifetime cast, can be done safely
+ /// # self
+ /// # }
+ /// #
+ /// # unsafe fn make(from: Bar<'a>) -> Self {
+ /// # let ret = mem::transmute_copy(&from);
+ /// # mem::forget(from);
+ /// # ret
+ /// # }
+ /// #
+ /// # fn transform_mut<F>(&'a mut self, f: F)
+ /// # where
+ /// # F: 'static + FnOnce(&'a mut Self::Output),
+ /// # {
+ /// # unsafe { f(mem::transmute(self)) }
+ /// # }
+ /// # }
+ /// ```
+ //
+ // Safety docs can be found at the end of the file.
+ pub fn map_project<P, F>(self, f: F) -> Yoke<P, C>
+ where
+ P: for<'a> Yokeable<'a>,
+ F: for<'a> FnOnce(
+ <Y as Yokeable<'a>>::Output,
+ PhantomData<&'a ()>,
+ ) -> <P as Yokeable<'a>>::Output,
+ {
+ let p = f(self.yokeable.into_inner().transform_owned(), PhantomData);
+ Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart,
+ }
+ }
+
+ /// This is similar to [`Yoke::map_project`], however it does not move
+ /// [`Self`] and instead clones the cart (only if the cart is a [`CloneableCart`])
+ ///
+ /// This is a bit more efficient than cloning the [`Yoke`] and then calling [`Yoke::map_project`]
+ /// because then it will not clone fields that are going to be discarded.
+ pub fn map_project_cloned<'this, P, F>(&'this self, f: F) -> Yoke<P, C>
+ where
+ P: for<'a> Yokeable<'a>,
+ C: CloneableCart,
+ F: for<'a> FnOnce(
+ &'this <Y as Yokeable<'a>>::Output,
+ PhantomData<&'a ()>,
+ ) -> <P as Yokeable<'a>>::Output,
+ {
+ let p = f(self.get(), PhantomData);
+ Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart.clone(),
+ }
+ }
+
+ /// This is similar to [`Yoke::map_project`], however it can also bubble up an error
+ /// from the callback.
+ ///
+ /// ```
+ /// # use std::rc::Rc;
+ /// # use yoke::Yoke;
+ /// # use std::str::{self, Utf8Error};
+ /// #
+ /// fn slice(
+ /// y: Yoke<&'static [u8], Rc<[u8]>>,
+ /// ) -> Result<Yoke<&'static str, Rc<[u8]>>, Utf8Error> {
+ /// y.try_map_project(move |bytes, _| str::from_utf8(bytes))
+ /// }
+ /// ```
+ ///
+ /// This can also be used to create a yoke for a subfield
+ ///
+ /// ```
+ /// # use yoke::{Yoke, Yokeable};
+ /// # use std::mem;
+ /// # use std::rc::Rc;
+ /// # use std::str::{self, Utf8Error};
+ /// #
+ /// // also safely implements Yokeable<'a>
+ /// struct Bar<'a> {
+ /// bytes_1: &'a [u8],
+ /// string_2: &'a str,
+ /// }
+ ///
+ /// fn map_project_string_1(
+ /// bar: Yoke<Bar<'static>, Rc<[u8]>>,
+ /// ) -> Result<Yoke<&'static str, Rc<[u8]>>, Utf8Error> {
+ /// bar.try_map_project(|bar, _| str::from_utf8(bar.bytes_1))
+ /// }
+ ///
+ /// #
+ /// # unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+ /// # type Output = Bar<'a>;
+ /// # fn transform(&'a self) -> &'a Bar<'a> {
+ /// # self
+ /// # }
+ /// #
+ /// # fn transform_owned(self) -> Bar<'a> {
+ /// # // covariant lifetime cast, can be done safely
+ /// # self
+ /// # }
+ /// #
+ /// # unsafe fn make(from: Bar<'a>) -> Self {
+ /// # let ret = mem::transmute_copy(&from);
+ /// # mem::forget(from);
+ /// # ret
+ /// # }
+ /// #
+ /// # fn transform_mut<F>(&'a mut self, f: F)
+ /// # where
+ /// # F: 'static + FnOnce(&'a mut Self::Output),
+ /// # {
+ /// # unsafe { f(mem::transmute(self)) }
+ /// # }
+ /// # }
+ /// ```
+ pub fn try_map_project<P, F, E>(self, f: F) -> Result<Yoke<P, C>, E>
+ where
+ P: for<'a> Yokeable<'a>,
+ F: for<'a> FnOnce(
+ <Y as Yokeable<'a>>::Output,
+ PhantomData<&'a ()>,
+ ) -> Result<<P as Yokeable<'a>>::Output, E>,
+ {
+ let p = f(self.yokeable.into_inner().transform_owned(), PhantomData)?;
+ Ok(Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart,
+ })
+ }
+
+ /// This is similar to [`Yoke::try_map_project`], however it does not move
+ /// [`Self`] and instead clones the cart (only if the cart is a [`CloneableCart`])
+ ///
+ /// This is a bit more efficient than cloning the [`Yoke`] and then calling [`Yoke::map_project`]
+ /// because then it will not clone fields that are going to be discarded.
+ pub fn try_map_project_cloned<'this, P, F, E>(&'this self, f: F) -> Result<Yoke<P, C>, E>
+ where
+ P: for<'a> Yokeable<'a>,
+ C: CloneableCart,
+ F: for<'a> FnOnce(
+ &'this <Y as Yokeable<'a>>::Output,
+ PhantomData<&'a ()>,
+ ) -> Result<<P as Yokeable<'a>>::Output, E>,
+ {
+ let p = f(self.get(), PhantomData)?;
+ Ok(Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart.clone(),
+ })
+ }
+ /// This is similar to [`Yoke::map_project`], but it works around older versions
+ /// of Rust not being able to use `FnOnce` by using an explicit capture input.
+ /// See [#1061](https://github.com/unicode-org/icu4x/issues/1061).
+ ///
+ /// See the docs of [`Yoke::map_project`] for how this works.
+ pub fn map_project_with_explicit_capture<P, T>(
+ self,
+ capture: T,
+ f: for<'a> fn(
+ <Y as Yokeable<'a>>::Output,
+ capture: T,
+ PhantomData<&'a ()>,
+ ) -> <P as Yokeable<'a>>::Output,
+ ) -> Yoke<P, C>
+ where
+ P: for<'a> Yokeable<'a>,
+ {
+ let p = f(
+ self.yokeable.into_inner().transform_owned(),
+ capture,
+ PhantomData,
+ );
+ Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart,
+ }
+ }
+
+ /// This is similar to [`Yoke::map_project_cloned`], but it works around older versions
+ /// of Rust not being able to use `FnOnce` by using an explicit capture input.
+ /// See [#1061](https://github.com/unicode-org/icu4x/issues/1061).
+ ///
+ /// See the docs of [`Yoke::map_project_cloned`] for how this works.
+ pub fn map_project_cloned_with_explicit_capture<'this, P, T>(
+ &'this self,
+ capture: T,
+ f: for<'a> fn(
+ &'this <Y as Yokeable<'a>>::Output,
+ capture: T,
+ PhantomData<&'a ()>,
+ ) -> <P as Yokeable<'a>>::Output,
+ ) -> Yoke<P, C>
+ where
+ P: for<'a> Yokeable<'a>,
+ C: CloneableCart,
+ {
+ let p = f(self.get(), capture, PhantomData);
+ Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart.clone(),
+ }
+ }
+
+ /// This is similar to [`Yoke::try_map_project`], but it works around older versions
+ /// of Rust not being able to use `FnOnce` by using an explicit capture input.
+ /// See [#1061](https://github.com/unicode-org/icu4x/issues/1061).
+ ///
+ /// See the docs of [`Yoke::try_map_project`] for how this works.
+ #[allow(clippy::type_complexity)]
+ pub fn try_map_project_with_explicit_capture<P, T, E>(
+ self,
+ capture: T,
+ f: for<'a> fn(
+ <Y as Yokeable<'a>>::Output,
+ capture: T,
+ PhantomData<&'a ()>,
+ ) -> Result<<P as Yokeable<'a>>::Output, E>,
+ ) -> Result<Yoke<P, C>, E>
+ where
+ P: for<'a> Yokeable<'a>,
+ {
+ let p = f(
+ self.yokeable.into_inner().transform_owned(),
+ capture,
+ PhantomData,
+ )?;
+ Ok(Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart,
+ })
+ }
+
+ /// This is similar to [`Yoke::try_map_project_cloned`], but it works around older versions
+ /// of Rust not being able to use `FnOnce` by using an explicit capture input.
+ /// See [#1061](https://github.com/unicode-org/icu4x/issues/1061).
+ ///
+ /// See the docs of [`Yoke::try_map_project_cloned`] for how this works.
+ #[allow(clippy::type_complexity)]
+ pub fn try_map_project_cloned_with_explicit_capture<'this, P, T, E>(
+ &'this self,
+ capture: T,
+ f: for<'a> fn(
+ &'this <Y as Yokeable<'a>>::Output,
+ capture: T,
+ PhantomData<&'a ()>,
+ ) -> Result<<P as Yokeable<'a>>::Output, E>,
+ ) -> Result<Yoke<P, C>, E>
+ where
+ P: for<'a> Yokeable<'a>,
+ C: CloneableCart,
+ {
+ let p = f(self.get(), capture, PhantomData)?;
+ Ok(Yoke {
+ yokeable: KindaSortaDangling::new(
+ // Safety: the resulting `yokeable` is dropped before the `cart` because
+ // of the Yoke invariant. See the safety docs below for the justification of why
+ // yokeable could only borrow from the Cart.
+ unsafe { P::make(p) },
+ ),
+ cart: self.cart.clone(),
+ })
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<Y: for<'a> Yokeable<'a>, C: 'static + Sized> Yoke<Y, Rc<C>> {
+ /// Allows type-erasing the cart in a `Yoke<Y, Rc<C>>`.
+ ///
+ /// The yoke only carries around a cart type `C` for its destructor,
+ /// since it needs to be able to guarantee that its internal references
+ /// are valid for the lifetime of the Yoke. As such, the actual type of the
+ /// Cart is not very useful unless you wish to extract data out of it
+ /// via [`Yoke::backing_cart()`]. Erasing the cart allows for one to mix
+ /// [`Yoke`]s obtained from different sources.
+ ///
+ /// In case the cart type `C` is not already an `Rc<T>`, you can use
+ /// [`Yoke::wrap_cart_in_rc()`] to wrap it.
+ ///
+ /// âš *Enabled with the `alloc` Cargo feature.*
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// use std::rc::Rc;
+ /// use yoke::erased::ErasedRcCart;
+ /// use yoke::Yoke;
+ ///
+ /// let buffer1: Rc<String> = Rc::new(" foo bar baz ".into());
+ /// let buffer2: Box<String> = Box::new(" baz quux ".into());
+ ///
+ /// let yoke1 =
+ /// Yoke::<&'static str, _>::attach_to_cart(buffer1, |rc| rc.trim());
+ /// let yoke2 = Yoke::<&'static str, _>::attach_to_cart(buffer2, |b| b.trim());
+ ///
+ /// let erased1: Yoke<_, ErasedRcCart> = yoke1.erase_rc_cart();
+ /// // Wrap the Box in an Rc to make it compatible
+ /// let erased2: Yoke<_, ErasedRcCart> =
+ /// yoke2.wrap_cart_in_rc().erase_rc_cart();
+ ///
+ /// // Now erased1 and erased2 have the same type!
+ /// ```
+ pub fn erase_rc_cart(self) -> Yoke<Y, ErasedRcCart> {
+ // Safety: safe because the cart is preserved, as it is just type-erased
+ unsafe { self.replace_cart(|c| c as ErasedRcCart) }
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<Y: for<'a> Yokeable<'a>, C: 'static + Sized + Send + Sync> Yoke<Y, Arc<C>> {
+ /// Allows type-erasing the cart in a `Yoke<Y, Arc<C>>`.
+ ///
+ /// The yoke only carries around a cart type `C` for its destructor,
+ /// since it needs to be able to guarantee that its internal references
+ /// are valid for the lifetime of the Yoke. As such, the actual type of the
+ /// Cart is not very useful unless you wish to extract data out of it
+ /// via [`Yoke::backing_cart()`]. Erasing the cart allows for one to mix
+ /// [`Yoke`]s obtained from different sources.
+ ///
+ /// In case the cart type `C` is not already an `Arc<T>`, you can use
+ /// [`Yoke::wrap_cart_in_arc()`] to wrap it.
+ ///
+ /// âš *Enabled with the `alloc` Cargo feature.*
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// use std::sync::Arc;
+ /// use yoke::erased::ErasedArcCart;
+ /// use yoke::Yoke;
+ ///
+ /// let buffer1: Arc<String> = Arc::new(" foo bar baz ".into());
+ /// let buffer2: Box<String> = Box::new(" baz quux ".into());
+ ///
+ /// let yoke1 =
+ /// Yoke::<&'static str, _>::attach_to_cart(buffer1, |arc| arc.trim());
+ /// let yoke2 = Yoke::<&'static str, _>::attach_to_cart(buffer2, |b| b.trim());
+ ///
+ /// let erased1: Yoke<_, ErasedArcCart> = yoke1.erase_arc_cart();
+ /// // Wrap the Box in an Rc to make it compatible
+ /// let erased2: Yoke<_, ErasedArcCart> =
+ /// yoke2.wrap_cart_in_arc().erase_arc_cart();
+ ///
+ /// // Now erased1 and erased2 have the same type!
+ /// ```
+ pub fn erase_arc_cart(self) -> Yoke<Y, ErasedArcCart> {
+ // Safety: safe because the cart is preserved, as it is just type-erased
+ unsafe { self.replace_cart(|c| c as ErasedArcCart) }
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<Y: for<'a> Yokeable<'a>, C: 'static + Sized> Yoke<Y, Box<C>> {
+ /// Allows type-erasing the cart in a `Yoke<Y, Box<C>>`.
+ ///
+ /// The yoke only carries around a cart type `C` for its destructor,
+ /// since it needs to be able to guarantee that its internal references
+ /// are valid for the lifetime of the Yoke. As such, the actual type of the
+ /// Cart is not very useful unless you wish to extract data out of it
+ /// via [`Yoke::backing_cart()`]. Erasing the cart allows for one to mix
+ /// [`Yoke`]s obtained from different sources.
+ ///
+ /// In case the cart type `C` is not already `Box<T>`, you can use
+ /// [`Yoke::wrap_cart_in_box()`] to wrap it.
+ ///
+ /// âš *Enabled with the `alloc` Cargo feature.*
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// use std::rc::Rc;
+ /// use yoke::erased::ErasedBoxCart;
+ /// use yoke::Yoke;
+ ///
+ /// let buffer1: Rc<String> = Rc::new(" foo bar baz ".into());
+ /// let buffer2: Box<String> = Box::new(" baz quux ".into());
+ ///
+ /// let yoke1 =
+ /// Yoke::<&'static str, _>::attach_to_cart(buffer1, |rc| rc.trim());
+ /// let yoke2 = Yoke::<&'static str, _>::attach_to_cart(buffer2, |b| b.trim());
+ ///
+ /// // Wrap the Rc in an Box to make it compatible
+ /// let erased1: Yoke<_, ErasedBoxCart> =
+ /// yoke1.wrap_cart_in_box().erase_box_cart();
+ /// let erased2: Yoke<_, ErasedBoxCart> = yoke2.erase_box_cart();
+ ///
+ /// // Now erased1 and erased2 have the same type!
+ /// ```
+ pub fn erase_box_cart(self) -> Yoke<Y, ErasedBoxCart> {
+ // Safety: safe because the cart is preserved, as it is just type-erased
+ unsafe { self.replace_cart(|c| c as ErasedBoxCart) }
+ }
+}
+
+#[cfg(feature = "alloc")]
+impl<Y: for<'a> Yokeable<'a>, C> Yoke<Y, C> {
+ /// Helper function allowing one to wrap the cart type `C` in a `Box<T>`.
+ /// Can be paired with [`Yoke::erase_box_cart()`]
+ ///
+ /// âš *Enabled with the `alloc` Cargo feature.*
+ #[inline]
+ pub fn wrap_cart_in_box(self) -> Yoke<Y, Box<C>> {
+ // Safety: safe because the cart is preserved, as it is just wrapped.
+ unsafe { self.replace_cart(Box::new) }
+ }
+ /// Helper function allowing one to wrap the cart type `C` in an `Rc<T>`.
+ /// Can be paired with [`Yoke::erase_rc_cart()`], or generally used
+ /// to make the [`Yoke`] cloneable.
+ ///
+ /// âš *Enabled with the `alloc` Cargo feature.*
+ #[inline]
+ pub fn wrap_cart_in_rc(self) -> Yoke<Y, Rc<C>> {
+ // Safety: safe because the cart is preserved, as it is just wrapped
+ unsafe { self.replace_cart(Rc::new) }
+ }
+ /// Helper function allowing one to wrap the cart type `C` in an `Rc<T>`.
+ /// Can be paired with [`Yoke::erase_arc_cart()`], or generally used
+ /// to make the [`Yoke`] cloneable.
+ ///
+ /// âš *Enabled with the `alloc` Cargo feature.*
+ #[inline]
+ pub fn wrap_cart_in_arc(self) -> Yoke<Y, Arc<C>> {
+ // Safety: safe because the cart is preserved, as it is just wrapped
+ unsafe { self.replace_cart(Arc::new) }
+ }
+}
+
+impl<Y: for<'a> Yokeable<'a>, C> Yoke<Y, C> {
+ /// Helper function allowing one to wrap the cart type `C` in an [`EitherCart`].
+ ///
+ /// This function wraps the cart into the `A` variant. To wrap it into the
+ /// `B` variant, use [`Self::wrap_cart_in_either_b()`].
+ ///
+ /// For an example, see [`EitherCart`].
+ #[inline]
+ pub fn wrap_cart_in_either_a<B>(self) -> Yoke<Y, EitherCart<C, B>> {
+ // Safety: safe because the cart is preserved, as it is just wrapped.
+ unsafe { self.replace_cart(EitherCart::A) }
+ }
+ /// Helper function allowing one to wrap the cart type `C` in an [`EitherCart`].
+ ///
+ /// This function wraps the cart into the `B` variant. To wrap it into the
+ /// `A` variant, use [`Self::wrap_cart_in_either_a()`].
+ ///
+ /// For an example, see [`EitherCart`].
+ #[inline]
+ pub fn wrap_cart_in_either_b<A>(self) -> Yoke<Y, EitherCart<A, C>> {
+ // Safety: safe because the cart is preserved, as it is just wrapped.
+ unsafe { self.replace_cart(EitherCart::B) }
+ }
+}
+
+/// # Safety docs for project()
+///
+/// (Docs are on a private const to allow the use of compile_fail doctests)
+///
+/// This is safe to perform because of the choice of lifetimes on `f`, that is,
+/// `for<a> fn(<Y as Yokeable<'a>>::Output, &'a ()) -> <P as Yokeable<'a>>::Output`.
+///
+/// Note that correctness arguments are similar if you replace `fn` with `FnOnce`.
+///
+/// What we want this function to do is take a Yokeable (`Y`) that is borrowing from the cart, and
+/// produce another Yokeable (`P`) that also borrows from the same cart. There are a couple potential
+/// hazards here:
+///
+/// - `P` ends up borrowing data from `Y` (or elsewhere) that did _not_ come from the cart,
+/// for example `P` could borrow owned data from a `Cow`. This would make the `Yoke<P>` dependent
+/// on data owned only by the `Yoke<Y>`.
+/// - Borrowed data from `Y` escapes with the wrong lifetime
+///
+/// Let's walk through these and see how they're prevented.
+///
+/// ```rust, compile_fail
+/// # use std::rc::Rc;
+/// # use yoke::Yoke;
+/// # use std::borrow::Cow;
+/// fn borrow_potentially_owned(y: &Yoke<Cow<'static, str>, Rc<[u8]>>) -> Yoke<&'static str, Rc<[u8]>> {
+/// y.map_project_cloned(|cow, _| &*cow)
+/// }
+/// ```
+///
+/// In this case, the lifetime of `&*cow` is `&'this str`, however the function needs to be able to return
+/// `&'a str` _for all `'a`_, which isn't possible.
+///
+///
+/// ```rust, compile_fail
+/// # use std::rc::Rc;
+/// # use yoke::Yoke;
+/// # use std::borrow::Cow;
+/// fn borrow_potentially_owned(y: Yoke<Cow<'static, str>, Rc<[u8]>>) -> Yoke<&'static str, Rc<[u8]>> {
+/// y.map_project(|cow, _| &*cow)
+/// }
+/// ```
+///
+/// This has the same issue, `&*cow` is borrowing for a local lifetime.
+///
+/// Similarly, trying to project an owned field of a struct will produce similar errors:
+///
+/// ```rust,compile_fail
+/// # use std::borrow::Cow;
+/// # use yoke::{Yoke, Yokeable};
+/// # use std::mem;
+/// # use std::rc::Rc;
+/// #
+/// // also safely implements Yokeable<'a>
+/// struct Bar<'a> {
+/// owned: String,
+/// string_2: &'a str,
+/// }
+///
+/// fn map_project_owned(bar: &Yoke<Bar<'static>, Rc<[u8]>>) -> Yoke<&'static str, Rc<[u8]>> {
+/// // ERROR (but works if you replace owned with string_2)
+/// bar.map_project_cloned(|bar, _| &*bar.owned)
+/// }
+///
+/// #
+/// # unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+/// # type Output = Bar<'a>;
+/// # fn transform(&'a self) -> &'a Bar<'a> {
+/// # self
+/// # }
+/// #
+/// # fn transform_owned(self) -> Bar<'a> {
+/// # // covariant lifetime cast, can be done safely
+/// # self
+/// # }
+/// #
+/// # unsafe fn make(from: Bar<'a>) -> Self {
+/// # let ret = mem::transmute_copy(&from);
+/// # mem::forget(from);
+/// # ret
+/// # }
+/// #
+/// # fn transform_mut<F>(&'a mut self, f: F)
+/// # where
+/// # F: 'static + FnOnce(&'a mut Self::Output),
+/// # {
+/// # unsafe { f(mem::transmute(self)) }
+/// # }
+/// # }
+/// ```
+///
+/// Borrowed data from `Y` similarly cannot escape with the wrong lifetime because of the `for<'a>`, since
+/// it will never be valid for the borrowed data to escape for all lifetimes of 'a. Internally, `.project()`
+/// uses `.get()`, however the signature forces the callers to be able to handle every lifetime.
+///
+/// `'a` is the only lifetime that matters here; `Yokeable`s must be `'static` and since
+/// `Output` is an associated type it can only have one lifetime, `'a` (there's nowhere for it to get another from).
+/// `Yoke`s can get additional lifetimes via the cart, and indeed, `project()` can operate on `Yoke<_, &'b [u8]>`,
+/// however this lifetime is inaccessible to the closure, and even if it were accessible the `for<'a>` would force
+/// it out of the output. All external lifetimes (from other found outside the yoke/closures
+/// are similarly constrained here.
+///
+/// Essentially, safety is achieved by using `for<'a> fn(...)` with `'a` used in both `Yokeable`s to ensure that
+/// the output yokeable can _only_ have borrowed data flow in to it from the input. All paths of unsoundness require the
+/// unification of an existential and universal lifetime, which isn't possible.
+const _: () = ();
+
+/// # Safety docs for attach_to_cart()'s signature
+///
+/// The `attach_to_cart()` family of methods get by by using the following bound:
+///
+/// ```rust,ignore
+/// F: for<'de> FnOnce(&'de <C as Deref>::Target) -> <Y as Yokeable<'de>>::Output,
+/// C::Target: 'static
+/// ```
+///
+/// to enforce that the yoking closure produces a yokeable that is *only* allowed to borrow from the cart.
+/// A way to be sure of this is as follows: imagine if `F` *did* borrow data of lifetime `'a` and stuff it in
+/// its output. Then that lifetime `'a` would have to live at least as long as `'de` *for all `'de`*.
+/// The only lifetime that satisfies that is `'static` (since at least one of the potential `'de`s is `'static`),
+/// and we're fine with that.
+///
+/// ## Implied bounds and variance
+///
+/// The `C::Target: 'static` bound is tricky, however. Let's imagine a situation where we *didn't* have that bound.
+///
+/// One thing to remember is that we are okay with the cart itself borrowing from places,
+/// e.g. `&[u8]` is a valid cart, as is `Box<&[u8]>`. `C` is not `'static`.
+///
+/// (I'm going to use `CT` in prose to refer to `C::Target` here, since almost everything here has to do
+/// with C::Target and not C itself.)
+///
+/// Unfortunately, there's a sneaky additional bound inside `F`. The signature of `F` is *actually*
+///
+/// ```rust,ignore
+/// F: for<'de> where<C::Target: 'de> FnOnce(&'de C::Target) -> <Y as Yokeable<'de>>::Output
+/// ```
+///
+/// using made-up "where clause inside HRTB" syntax to represent a type that can be represented inside the compiler
+/// and type system but not in Rust code. The `CT: 'de` bond comes from the `&'de C::Target`: any time you
+/// write `&'a T`, an implied bound of `T: 'a` materializes and is stored alongside it, since references cannot refer
+/// to data that itself refers to data of shorter lifetimes. If a reference is valid, its referent must be valid for
+/// the duration of the reference's lifetime, so every reference *inside* its referent must also be valid, giving us `T: 'a`.
+/// This kind of constraint is often called a "well formedness" constraint: `&'a T` is not "well formed" without that
+/// bound, and rustc is being helpful by giving it to us for free.
+///
+/// Unfortunately, this messes with our universal quantification. The `for<'de>` is no longer "For all lifetimes `'de`",
+/// it is "for all lifetimes `'de` *where `CT: 'de`*". And if `CT` borrows from somewhere (with lifetime `'ct`), then we get a
+/// `'ct: 'de` bound, and `'de` candidates that live longer than `'ct` won't actually be considered.
+/// The neat little logic at the beginning stops working.
+///
+/// `attach_to_cart()` will instead enforce that the produced yokeable *either* borrows from the cart (fine), or from
+/// data that has a lifetime that is at least `'ct`. Which means that `attach_to_cart()` will allow us to borrow locals
+/// provided they live at least as long as `'ct`.
+///
+/// Is this a problem?
+///
+/// This is totally fine if CT's lifetime is covariant: if C is something like `Box<&'ct [u8]>`, even if our
+/// yoked object borrows from locals outliving `'ct`, our Yoke can't outlive that
+/// lifetime `'ct` anyway (since it's a part of the cart type), so we're fine.
+///
+/// However it's completely broken for contravariant carts (e.g. `Box<fn(&'ct u8)>`). In that case
+/// we still get `'ct: 'de`, and we still end up being able to
+/// borrow from locals that outlive `'ct`. However, our Yoke _can_ outlive
+/// that lifetime, because Yoke shares its variance over `'ct`
+/// with the cart type, and the cart type is contravariant over `'ct`.
+/// So the Yoke can be upcast to having a longer lifetime than `'ct`, and *that* Yoke
+/// can outlive `'ct`.
+///
+/// We fix this by forcing `C::Target: 'static` in `attach_to_cart()`, which would make it work
+/// for fewer types, but would also allow Yoke to continue to be covariant over cart lifetimes if necessary.
+///
+/// An alternate fix would be to not allowing yoke to ever be upcast over lifetimes contained in the cart
+/// by forcing them to be invariant. This is a bit more restrictive and affects *all* `Yoke` users, not just
+/// those using `attach_to_cart()`.
+///
+/// See https://github.com/unicode-org/icu4x/issues/2926
+/// See also https://github.com/rust-lang/rust/issues/106431 for potentially fixing this upstream by
+/// changing how the bound works.
+///
+/// # Tests
+///
+/// Here's a broken `attach_to_cart()` that attempts to borrow from a local:
+///
+/// ```rust,compile_fail
+/// use yoke::Yoke;
+///
+/// let cart = vec![1, 2, 3, 4].into_boxed_slice();
+/// let local = vec![4, 5, 6, 7];
+/// let yoke: Yoke<&[u8], Box<[u8]>> = Yoke::attach_to_cart(cart, |_| &*local);
+/// ```
+///
+/// Fails as expected.
+///
+/// And here's a working one with a local borrowed cart that does not do any sneaky borrows whilst attaching.
+///
+/// ```rust
+/// use yoke::Yoke;
+///
+/// let cart = vec![1, 2, 3, 4].into_boxed_slice();
+/// let local = vec![4, 5, 6, 7];
+/// let yoke: Yoke<&[u8], &[u8]> = Yoke::attach_to_cart(&cart, |c| &*c);
+/// ```
+///
+/// Here's an `attach_to_cart()` that attempts to borrow from a longer-lived local due to
+/// the cart being covariant. It fails, but would not if the alternate fix of forcing Yoke to be invariant
+/// were implemented. It is technically a safe operation:
+///
+/// ```rust,compile_fail
+/// use yoke::Yoke;
+/// // longer lived
+/// let local = vec![4, 5, 6, 7];
+///
+/// let backing = vec![1, 2, 3, 4];
+/// let cart = Box::new(&*backing);
+///
+/// let yoke: Yoke<&[u8], Box<&[u8]>> = Yoke::attach_to_cart(cart, |_| &*local);
+/// println!("{:?}", yoke.get());
+/// ```
+///
+/// Finally, here's an `attach_to_cart()` that attempts to borrow from a longer lived local
+/// in the case of a contravariant lifetime. It does not compile, but in and of itself is not dangerous:
+///
+/// ```rust,compile_fail
+/// use yoke::Yoke;
+///
+/// type Contra<'a> = fn(&'a ());
+///
+/// let local = String::from("Hello World!");
+/// let yoke: Yoke<&'static str, Box<Contra<'_>>> = Yoke::attach_to_cart(Box::new((|_| {}) as _), |_| &local[..]);
+/// println!("{:?}", yoke.get());
+/// ```
+///
+/// It is dangerous if allowed to transform (testcase from #2926)
+///
+/// ```rust,compile_fail
+/// use yoke::Yoke;
+///
+/// type Contra<'a> = fn(&'a ());
+///
+///
+/// let local = String::from("Hello World!");
+/// let yoke: Yoke<&'static str, Box<Contra<'_>>> = Yoke::attach_to_cart(Box::new((|_| {}) as _), |_| &local[..]);
+/// println!("{:?}", yoke.get());
+/// let yoke_longer: Yoke<&'static str, Box<Contra<'static>>> = yoke;
+/// let leaked: &'static Yoke<&'static str, Box<Contra<'static>>> = Box::leak(Box::new(yoke_longer));
+/// let reference: &'static str = leaked.get();
+///
+/// println!("pre-drop: {reference}");
+/// drop(local);
+/// println!("post-drop: {reference}");
+/// ```
+const _: () = ();
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yokeable.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yokeable.rs
new file mode 100644
index 0000000..36fc203
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yokeable.rs
@@ -0,0 +1,369 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+#[cfg(feature = "alloc")]
+use alloc::borrow::{Cow, ToOwned};
+use core::{marker::PhantomData, mem};
+
+/// The `Yokeable<'a>` trait is implemented on the `'static` version of any zero-copy type; for
+/// example, `Cow<'static, T>` implements `Yokeable<'a>` (for all `'a`).
+///
+/// One can use
+/// `Yokeable::Output` on this trait to obtain the "lifetime'd" value of the `Cow<'static, T>`,
+/// e.g. `<Cow<'static, T> as Yokeable<'a>'>::Output` is `Cow<'a, T>`.
+///
+/// A [`Yokeable`] type is essentially one with a covariant lifetime parameter,
+/// matched to the parameter in the trait definition. The trait allows one to cast
+/// the covariant lifetime to and from `'static`.
+///
+/// **Most of the time, if you need to implement [`Yokeable`], you should be able to use the safe
+/// [`#[derive(Yokeable)]`](yoke_derive::Yokeable) custom derive.**
+///
+/// While Rust does not yet have GAT syntax, for the purpose of this documentation
+/// we shall refer to "`Self` with a lifetime `'a`" with the syntax `Self<'a>`.
+/// Self<'static> is a stand-in for the HKT Self<'_>: lifetime -> type.
+///
+/// With this terminology, [`Yokeable`] exposes ways to cast between `Self<'static>` and `Self<'a>` generically.
+/// This is useful for turning covariant lifetimes to _dynamic_ lifetimes, where `'static` is
+/// used as a way to "erase" the lifetime.
+///
+/// # Safety
+///
+/// This trait is safe to implement on types with a _covariant_ lifetime parameter, i.e. one where
+/// [`Self::transform()`]'s body can simply be `{ self }`. This will occur when the lifetime
+/// parameter is used within references, but not in the arguments of function pointers or in mutable
+/// positions (either in `&mut` or via interior mutability)
+///
+/// This trait must be implemented on the `'static` version of such a type, e.g. one should
+/// implement `Yokeable<'a>` (for all `'a`) on `Cow<'static, T>`.
+///
+/// This trait is also safe to implement on types that do not borrow memory.
+///
+/// There are further constraints on implementation safety on individual methods.
+///
+/// # Implementation example
+///
+/// Implementing this trait manually is unsafe. Where possible, you should use the safe
+/// [`#[derive(Yokeable)]`](yoke_derive::Yokeable) custom derive instead. We include an example
+/// in case you have your own zero-copy abstractions you wish to make yokeable.
+///
+/// ```rust
+/// # use yoke::Yokeable;
+/// # use std::borrow::Cow;
+/// # use std::{mem, ptr};
+/// struct Bar<'a> {
+/// numbers: Cow<'a, [u8]>,
+/// string: Cow<'a, str>,
+/// owned: Vec<u8>,
+/// }
+///
+/// unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+/// type Output = Bar<'a>;
+/// fn transform(&'a self) -> &'a Bar<'a> {
+/// // covariant lifetime cast, can be done safely
+/// self
+/// }
+///
+/// fn transform_owned(self) -> Bar<'a> {
+/// // covariant lifetime cast, can be done safely
+/// self
+/// }
+///
+/// unsafe fn make(from: Bar<'a>) -> Self {
+/// // We're just doing mem::transmute() here, however Rust is
+/// // not smart enough to realize that Bar<'a> and Bar<'static> are of
+/// // the same size, so instead we use transmute_copy
+///
+/// // This assert will be optimized out, but is included for additional
+/// // peace of mind as we are using transmute_copy
+/// debug_assert!(mem::size_of::<Bar<'a>>() == mem::size_of::<Self>());
+/// let ptr: *const Self = (&from as *const Self::Output).cast();
+/// mem::forget(from);
+/// ptr::read(ptr)
+/// }
+///
+/// fn transform_mut<F>(&'a mut self, f: F)
+/// where
+/// F: 'static + FnOnce(&'a mut Self::Output),
+/// {
+/// unsafe { f(mem::transmute::<&mut Self, &mut Self::Output>(self)) }
+/// }
+/// }
+/// ```
+pub unsafe trait Yokeable<'a>: 'static {
+ /// This type MUST be `Self` with the `'static` replaced with `'a`, i.e. `Self<'a>`
+ type Output: 'a;
+
+ /// This method must cast `self` between `&'a Self<'static>` and `&'a Self<'a>`.
+ ///
+ /// # Implementation safety
+ ///
+ /// If the invariants of [`Yokeable`] are being satisfied, the body of this method
+ /// should simply be `{ self }`, though it's acceptable to include additional assertions
+ /// if desired.
+ fn transform(&'a self) -> &'a Self::Output;
+
+ /// This method must cast `self` between `Self<'static>` and `Self<'a>`.
+ ///
+ /// # Implementation safety
+ ///
+ /// If the invariants of [`Yokeable`] are being satisfied, the body of this method
+ /// should simply be `{ self }`, though it's acceptable to include additional assertions
+ /// if desired.
+ fn transform_owned(self) -> Self::Output;
+
+ /// This method can be used to cast away `Self<'a>`'s lifetime.
+ ///
+ /// # Safety
+ ///
+ /// The returned value must be destroyed before the data `from` was borrowing from is.
+ ///
+ /// # Implementation safety
+ ///
+ /// A safe implementation of this method must be equivalent to a transmute between
+ /// `Self<'a>` and `Self<'static>`
+ unsafe fn make(from: Self::Output) -> Self;
+
+ /// This method must cast `self` between `&'a mut Self<'static>` and `&'a mut Self<'a>`,
+ /// and pass it to `f`.
+ ///
+ /// # Implementation safety
+ ///
+ /// A safe implementation of this method must be equivalent to a pointer cast/transmute between
+ /// `&mut Self<'a>` and `&mut Self<'static>` being passed to `f`
+ ///
+ /// # Why is this safe?
+ ///
+ /// Typically covariant lifetimes become invariant when hidden behind an `&mut`,
+ /// which is why the implementation of this method cannot just be `f(self)`.
+ /// The reason behind this is that while _reading_ a covariant lifetime that has been cast to a shorter
+ /// one is always safe (this is roughly the definition of a covariant lifetime), writing
+ /// may not necessarily be safe since you could write a smaller reference to it. For example,
+ /// the following code is unsound because it manages to stuff a `'a` lifetime into a `Cow<'static>`
+ ///
+ /// ```rust,compile_fail
+ /// # use std::borrow::Cow;
+ /// # use yoke::Yokeable;
+ /// struct Foo {
+ /// str: String,
+ /// cow: Cow<'static, str>,
+ /// }
+ ///
+ /// fn unsound<'a>(foo: &'a mut Foo) {
+ /// let a: &str = &foo.str;
+ /// foo.cow.transform_mut(|cow| *cow = Cow::Borrowed(a));
+ /// }
+ /// ```
+ ///
+ /// However, this code will not compile because [`Yokeable::transform_mut()`] requires `F: 'static`.
+ /// This enforces that while `F` may mutate `Self<'a>`, it can only mutate it in a way that does
+ /// not insert additional references. For example, `F` may call `to_owned()` on a `Cow` and mutate it,
+ /// but it cannot insert a new _borrowed_ reference because it has nowhere to borrow _from_ --
+ /// `f` does not contain any borrowed references, and while we give it `Self<'a>` (which contains borrowed
+ /// data), that borrowed data is known to be valid
+ ///
+ /// Note that the `for<'b>` is also necessary, otherwise the following code would compile:
+ ///
+ /// ```rust,compile_fail
+ /// # use std::borrow::Cow;
+ /// # use yoke::Yokeable;
+ /// # use std::mem;
+ /// #
+ /// // also safely implements Yokeable<'a>
+ /// struct Bar<'a> {
+ /// num: u8,
+ /// cow: Cow<'a, u8>,
+ /// }
+ ///
+ /// fn unsound<'a>(bar: &'a mut Bar<'static>) {
+ /// bar.transform_mut(move |bar| bar.cow = Cow::Borrowed(&bar.num));
+ /// }
+ /// #
+ /// # unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+ /// # type Output = Bar<'a>;
+ /// # fn transform(&'a self) -> &'a Bar<'a> {
+ /// # self
+ /// # }
+ /// #
+ /// # fn transform_owned(self) -> Bar<'a> {
+ /// # // covariant lifetime cast, can be done safely
+ /// # self
+ /// # }
+ /// #
+ /// # unsafe fn make(from: Bar<'a>) -> Self {
+ /// # let ret = mem::transmute_copy(&from);
+ /// # mem::forget(from);
+ /// # ret
+ /// # }
+ /// #
+ /// # fn transform_mut<F>(&'a mut self, f: F)
+ /// # where
+ /// # F: 'static + FnOnce(&'a mut Self::Output),
+ /// # {
+ /// # unsafe { f(mem::transmute(self)) }
+ /// # }
+ /// # }
+ /// ```
+ ///
+ /// which is unsound because `bar` could be moved later, and we do not want to be able to
+ /// self-insert references to it.
+ ///
+ /// The `for<'b>` enforces this by stopping the author of the closure from matching up the input
+ /// `&'b Self::Output` lifetime with `'a` and borrowing directly from it.
+ ///
+ /// Thus the only types of mutations allowed are ones that move around already-borrowed data, or
+ /// introduce new owned data:
+ ///
+ /// ```rust
+ /// # use std::borrow::Cow;
+ /// # use yoke::Yokeable;
+ /// struct Foo {
+ /// str: String,
+ /// cow: Cow<'static, str>,
+ /// }
+ ///
+ /// fn sound<'a>(foo: &'a mut Foo) {
+ /// foo.cow.transform_mut(move |cow| cow.to_mut().push('a'));
+ /// }
+ /// ```
+ ///
+ /// More formally, a reference to an object that `f` assigns to a reference
+ /// in Self<'a> could be obtained from:
+ /// - a local variable: the compiler rejects the assignment because 'a certainly
+ /// outlives local variables in f.
+ /// - a field in its argument: because of the for<'b> bound, the call to `f`
+ /// must be valid for a particular 'b that is strictly shorter than 'a. Thus,
+ /// the compiler rejects the assignment.
+ /// - a reference field in Self<'a>: this does not extend the set of
+ /// non-static lifetimes reachable from Self<'a>, so this is fine.
+ /// - one of f's captures: since F: 'static, the resulting reference must refer
+ /// to 'static data.
+ /// - a static or thread_local variable: ditto.
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ // be VERY CAREFUL changing this signature, it is very nuanced (see above)
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output);
+}
+
+#[cfg(feature = "alloc")]
+// Safety: Cow<'a, _> is covariant in 'a.
+unsafe impl<'a, T: 'static + ToOwned + ?Sized> Yokeable<'a> for Cow<'static, T>
+where
+ <T as ToOwned>::Owned: Sized,
+{
+ type Output = Cow<'a, T>;
+ #[inline]
+ fn transform(&'a self) -> &'a Cow<'a, T> {
+ // Doesn't need unsafe: `'a` is covariant so this lifetime cast is always safe
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> Cow<'a, T> {
+ // Doesn't need unsafe: `'a` is covariant so this lifetime cast is always safe
+ self
+ }
+ #[inline]
+ unsafe fn make(from: Cow<'a, T>) -> Self {
+ // i hate this
+ // unfortunately Rust doesn't think `mem::transmute` is possible since it's not sure the sizes
+ // are the same
+ debug_assert!(mem::size_of::<Cow<'a, T>>() == mem::size_of::<Self>());
+ let ptr: *const Self = (&from as *const Self::Output).cast();
+ let _ = core::mem::ManuallyDrop::new(from);
+ // Safety: `ptr` is certainly valid, aligned and points to a properly initialized value, as
+ // it comes from a value that was moved into a ManuallyDrop.
+ unsafe { core::ptr::read(ptr) }
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output),
+ {
+ // Cast away the lifetime of Self
+ // Safety: this is equivalent to f(transmute(self)), and the documentation of the trait
+ // method explains why doing so is sound.
+ unsafe { f(mem::transmute::<&'a mut Self, &'a mut Self::Output>(self)) }
+ }
+}
+
+// Safety: &'a T is covariant in 'a.
+unsafe impl<'a, T: 'static + ?Sized> Yokeable<'a> for &'static T {
+ type Output = &'a T;
+ #[inline]
+ fn transform(&'a self) -> &'a &'a T {
+ // Doesn't need unsafe: `'a` is covariant so this lifetime cast is always safe
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> &'a T {
+ // Doesn't need unsafe: `'a` is covariant so this lifetime cast is always safe
+ self
+ }
+ #[inline]
+ unsafe fn make(from: &'a T) -> Self {
+ // Safety: function safety invariant guarantees that the returned reference
+ // will never be used beyond its original lifetime.
+ unsafe { mem::transmute(from) }
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output),
+ {
+ // Cast away the lifetime of Self
+ // Safety: this is equivalent to f(transmute(self)), and the documentation of the trait
+ // method explains why doing so is sound.
+ unsafe { f(mem::transmute::<&'a mut Self, &'a mut Self::Output>(self)) }
+ }
+}
+
+#[cfg(feature = "alloc")]
+// Safety: Vec<T: 'static> never borrows.
+unsafe impl<'a, T: 'static> Yokeable<'a> for alloc::vec::Vec<T> {
+ type Output = alloc::vec::Vec<T>;
+ #[inline]
+ fn transform(&'a self) -> &'a alloc::vec::Vec<T> {
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> alloc::vec::Vec<T> {
+ self
+ }
+ #[inline]
+ unsafe fn make(from: alloc::vec::Vec<T>) -> Self {
+ from
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output),
+ {
+ f(self)
+ }
+}
+
+// Safety: PhantomData is a ZST.
+unsafe impl<'a, T: ?Sized + 'static> Yokeable<'a> for PhantomData<T> {
+ type Output = PhantomData<T>;
+
+ fn transform(&'a self) -> &'a Self::Output {
+ self
+ }
+
+ fn transform_owned(self) -> Self::Output {
+ self
+ }
+
+ unsafe fn make(from: Self::Output) -> Self {
+ from
+ }
+
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ // be VERY CAREFUL changing this signature, it is very nuanced (see above)
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output),
+ {
+ f(self)
+ }
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/zero_from.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/zero_from.rs
new file mode 100644
index 0000000..53e6d76
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/zero_from.rs
@@ -0,0 +1,44 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use crate::Yoke;
+use crate::Yokeable;
+
+use core::ops::Deref;
+use stable_deref_trait::StableDeref;
+
+use crate::ZeroFrom;
+
+impl<Y, C> Yoke<Y, C>
+where
+ Y: for<'a> Yokeable<'a>,
+ for<'a> <Y as Yokeable<'a>>::Output: ZeroFrom<'a, <C as Deref>::Target>,
+ C: StableDeref + Deref,
+ <C as Deref>::Target: 'static,
+{
+ /// Construct a [`Yoke`]`<Y, C>` from a cart implementing `StableDeref` by zero-copy cloning
+ /// the cart to `Y` and then yokeing that object to the cart.
+ ///
+ /// The type `Y` must implement [`ZeroFrom`]`<C::Target>`. This trait is auto-implemented
+ /// on many common types and can be custom implemented or derived in order to make it easier
+ /// to construct a `Yoke`.
+ ///
+ /// # Example
+ ///
+ /// Attach to a cart:
+ ///
+ /// ```
+ /// use std::borrow::Cow;
+ /// use yoke::Yoke;
+ ///
+ /// let yoke = Yoke::<Cow<'static, str>, String>::attach_to_zero_copy_cart(
+ /// "demo".to_owned(),
+ /// );
+ ///
+ /// assert_eq!("demo", yoke.get());
+ /// ```
+ pub fn attach_to_zero_copy_cart(cart: C) -> Self {
+ Yoke::<Y, C>::attach_to_cart(cart, |c| <Y as Yokeable>::Output::zero_from(c))
+ }
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/tests/bincode.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/tests/bincode.rs
new file mode 100644
index 0000000..653865e
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/tests/bincode.rs
@@ -0,0 +1,83 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+// This test is a duplicate of one of the doctests, but is written separately
+// since `cargo miri test` doesn't work on doctests yet
+
+use std::borrow::Cow;
+use std::mem;
+use std::rc::Rc;
+use yoke::{Yoke, Yokeable};
+
+fn load_from_cache(_filename: &str) -> Rc<[u8]> {
+ // dummy implementation
+ Rc::new([0x5, 0, 0, 0, 0, 0, 0, 0, 0x68, 0x65, 0x6c, 0x6c, 0x6f])
+}
+
+fn load_object(filename: &str) -> Yoke<Bar<'static>, Rc<[u8]>> {
+ let rc: Rc<[u8]> = load_from_cache(filename);
+ Yoke::<Bar<'static>, Rc<[u8]>>::attach_to_cart(rc, |data: &[u8]| {
+ // A real implementation would properly deserialize `Bar` as a whole
+ Bar {
+ numbers: Cow::Borrowed(bincode::deserialize(data).unwrap()),
+ string: Cow::Borrowed(bincode::deserialize(data).unwrap()),
+ owned: Vec::new(),
+ }
+ })
+}
+
+// also implements Yokeable
+struct Bar<'a> {
+ numbers: Cow<'a, [u8]>,
+ string: Cow<'a, str>,
+ owned: Vec<u8>,
+}
+
+unsafe impl<'a> Yokeable<'a> for Bar<'static> {
+ type Output = Bar<'a>;
+ #[inline]
+ fn transform(&'a self) -> &'a Bar<'a> {
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> Bar<'a> {
+ self
+ }
+ #[inline]
+ unsafe fn make(from: Bar<'a>) -> Self {
+ let ret = mem::transmute_copy(&from);
+ mem::forget(from);
+ ret
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + FnOnce(&'a mut Self::Output),
+ {
+ unsafe { f(mem::transmute::<&mut Bar<'_>, &mut Bar<'a>>(self)) }
+ }
+}
+
+#[test]
+fn test_load() {
+ // `load_object()` deserializes an object from a file
+ let mut bar = load_object("filename.bincode");
+ assert_eq!(bar.get().string, "hello");
+ assert!(matches!(bar.get().string, Cow::Borrowed(_)));
+ assert_eq!(&*bar.get().numbers, &[0x68, 0x65, 0x6c, 0x6c, 0x6f]);
+ assert!(matches!(bar.get().numbers, Cow::Borrowed(_)));
+ assert_eq!(&*bar.get().owned, &[]);
+
+ bar.with_mut(|bar| {
+ bar.string.to_mut().push_str(" world");
+ bar.owned.extend_from_slice(&[1, 4, 1, 5, 9]);
+ });
+
+ assert_eq!(bar.get().string, "hello world");
+ assert!(matches!(bar.get().string, Cow::Owned(_)));
+ assert_eq!(&*bar.get().owned, &[1, 4, 1, 5, 9]);
+ // Unchanged and still Cow::Borrowed
+ assert_eq!(&*bar.get().numbers, &[0x68, 0x65, 0x6c, 0x6c, 0x6f]);
+ assert!(matches!(bar.get().numbers, Cow::Borrowed(_)));
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/tests/miri.rs b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/tests/miri.rs
new file mode 100644
index 0000000..0b92af2
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/tests/miri.rs
@@ -0,0 +1,15 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+use yoke::Yoke;
+
+// Test for strong protection, should pass under miri with -Zmiri-retag-fields
+// See https://github.com/unicode-org/icu4x/issues/3696
+
+fn example(_: Yoke<&'static [u8], Vec<u8>>) {}
+
+#[test]
+fn run_test() {
+ example(Yoke::attach_to_cart(vec![0, 1, 2], |data| data));
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/.cargo-checksum.json
similarity index 100%
copy from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo-checksum.json
copy to third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/.cargo-checksum.json
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/.cargo_vcs_info.json
new file mode 100644
index 0000000..64466c4
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+ "git": {
+ "sha1": "f4290a877dfcb0f87cad6de4abdd65f0cbb33c9c"
+ },
+ "path_in_vcs": "utils/yoke/derive"
+}
\ No newline at end of file
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.lock b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.lock
new file mode 100644
index 0000000..18c750d
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.lock
@@ -0,0 +1,59 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.93"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.98"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "synstructure"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.toml
new file mode 100644
index 0000000..0e1fef2
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.toml
@@ -0,0 +1,66 @@
+# 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 = "2021"
+name = "yoke-derive"
+version = "0.8.0"
+authors = ["Manish Goregaokar <manishsmail@gmail.com>"]
+build = false
+autolib = false
+autobins = false
+autoexamples = false
+autotests = false
+autobenches = false
+description = "Custom derive for the yoke crate"
+readme = "README.md"
+keywords = [
+ "zerocopy",
+ "serialization",
+ "lifetime",
+ "borrow",
+ "self-referential",
+]
+categories = [
+ "data-structures",
+ "memory-management",
+ "caching",
+ "no-std",
+]
+license = "Unicode-3.0"
+repository = "https://github.com/unicode-org/icu4x"
+
+[package.metadata.workspaces]
+independent = true
+
+[lib]
+name = "yoke_derive"
+path = "src/lib.rs"
+proc-macro = true
+
+[[example]]
+name = "yoke_derive"
+path = "examples/yoke_derive.rs"
+
+[dependencies.proc-macro2]
+version = "1.0.61"
+
+[dependencies.quote]
+version = "1.0.28"
+
+[dependencies.syn]
+version = "2.0.21"
+features = ["fold"]
+
+[dependencies.synstructure]
+version = "0.13.0"
+
+[dev-dependencies]
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.toml.orig
new file mode 100644
index 0000000..8203afa
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/Cargo.toml.orig
@@ -0,0 +1,32 @@
+# This file is part of ICU4X. For terms of use, please see the file
+# called LICENSE at the top level of the ICU4X source tree
+# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+[package]
+name = "yoke-derive"
+description = "Custom derive for the yoke crate"
+version = "0.8.0"
+categories = ["data-structures", "memory-management", "caching", "no-std"]
+keywords = ["zerocopy", "serialization", "lifetime", "borrow", "self-referential"]
+authors = ["Manish Goregaokar <manishsmail@gmail.com>"]
+
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+
+[package.metadata.workspaces]
+independent = true
+
+[lib]
+proc-macro = true
+path = "src/lib.rs"
+
+[dependencies]
+proc-macro2 = { workspace = true }
+quote = { workspace = true }
+syn = { workspace = true, features = ["fold"] }
+synstructure = { workspace = true }
+
+[dev-dependencies]
+yoke = { path = "..", features = ["derive"] }
+zerovec = { path = "../../../utils/zerovec", features = ["yoke"] }
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/LICENSE
similarity index 100%
copy from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE
copy to third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/LICENSE
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/README.md b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/README.md
new file mode 100644
index 0000000..04ef27e0
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/README.md
@@ -0,0 +1,11 @@
+# yoke-derive [](https://crates.io/crates/yoke-derive)
+
+<!-- cargo-rdme start -->
+
+Custom derives for `Yokeable` from the `yoke` crate.
+
+<!-- cargo-rdme end -->
+
+## More Information
+
+For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/examples/yoke_derive.rs b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/examples/yoke_derive.rs
new file mode 100644
index 0000000..d65ada1b
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/examples/yoke_derive.rs
@@ -0,0 +1,108 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+#![allow(unused)]
+
+use std::{borrow::Cow, marker::PhantomData};
+use yoke::{Yoke, Yokeable};
+use zerovec::{maps::ZeroMapKV, ule::AsULE, VarZeroVec, ZeroMap, ZeroVec};
+
+#[derive(Yokeable)]
+pub struct StringExample {
+ x: String,
+}
+
+#[derive(Yokeable, Copy, Clone)]
+pub struct IntExample {
+ x: u32,
+}
+
+#[derive(Yokeable, Copy, Clone)]
+pub struct GenericsExample<T> {
+ x: u32,
+ y: T,
+}
+
+#[derive(Yokeable, Copy, Clone)]
+pub struct GenericsExampleWithDefault<T, U = usize> {
+ x: T,
+ y: U,
+}
+
+#[derive(Yokeable)]
+pub struct CowExample<'a> {
+ x: u8,
+ y: &'a str,
+ z: Cow<'a, str>,
+ w: Cow<'a, [u8]>,
+}
+
+#[derive(Yokeable)]
+pub struct ZeroVecExample<'a> {
+ var: VarZeroVec<'a, str>,
+ vec: ZeroVec<'a, u16>,
+}
+
+#[derive(Yokeable)]
+pub struct ZeroVecExampleWithGenerics<'a, T: AsULE> {
+ gen: ZeroVec<'a, T>,
+ vec: ZeroVec<'a, u16>,
+ bare: T,
+}
+
+// Since ZeroMap has generic parameters, the Rust compiler cannot
+// prove the covariance of the lifetimes. To use derive(Yokeable)
+// with a type such as ZeroMap, you just add the attribute
+// yoke(prove_covariance_manually)
+#[derive(Yokeable)]
+#[yoke(prove_covariance_manually)]
+pub struct ZeroMapExample<'a> {
+ map: ZeroMap<'a, str, u16>,
+}
+
+#[derive(Yokeable)]
+#[yoke(prove_covariance_manually)]
+pub struct ZeroMapGenericExample<'a, T: for<'b> ZeroMapKV<'b> + ?Sized> {
+ map: ZeroMap<'a, str, T>,
+}
+
+#[derive(Yokeable)]
+pub struct MaybeSizedWrap<T, Q: ?Sized, U: ?Sized> {
+ x: T,
+ y: Option<T>,
+ ignored: PhantomData<U>,
+ q: Q,
+}
+
+// TODO(#4119): Make this example compile
+/*
+#[derive(Yokeable)]
+pub struct MaybeSizedWrapWithLifetime<'a, T, Q: ?Sized, U: ?Sized> {
+ x: T,
+ y: Option<T>,
+ ignored: &'a U,
+ q: Q,
+}
+*/
+
+pub struct AssertYokeable {
+ string: Yoke<StringExample, Box<[u8]>>,
+ int: Yoke<IntExample, Box<[u8]>>,
+ gen1: Yoke<GenericsExample<u32>, Box<[u8]>>,
+ gen2: Yoke<GenericsExample<String>, Box<[u8]>>,
+ gen_default1: Yoke<GenericsExampleWithDefault<String>, Box<[u8]>>,
+ gen_default2: Yoke<GenericsExampleWithDefault<String, u8>, Box<[u8]>>,
+ cow: Yoke<CowExample<'static>, Box<[u8]>>,
+ zv: Yoke<ZeroVecExample<'static>, Box<[u8]>>,
+ zv_gen1: Yoke<ZeroVecExampleWithGenerics<'static, u8>, Box<[u8]>>,
+ zv_gen2: Yoke<ZeroVecExampleWithGenerics<'static, char>, Box<[u8]>>,
+ map: Yoke<ZeroMapExample<'static>, Box<[u8]>>,
+ map_gen1: Yoke<ZeroMapGenericExample<'static, u32>, Box<[u8]>>,
+ map_gen2: Yoke<ZeroMapGenericExample<'static, str>, Box<[u8]>>,
+ maybe_sized_wrap: Yoke<MaybeSizedWrap<usize, usize, str>, Box<[u8]>>,
+ // TODO(#4119): Make this example compile
+ // maybe_sized_wrap_with_lt: Yoke<MaybeSizedWrapWithLifetime<'static, usize, usize, str>, Box<[u8]>>,
+}
+
+fn main() {}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/lib.rs
new file mode 100644
index 0000000..4d3d8843
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/lib.rs
@@ -0,0 +1,273 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! Custom derives for `Yokeable` from the `yoke` crate.
+
+use proc_macro::TokenStream;
+use proc_macro2::{Span, TokenStream as TokenStream2};
+use quote::quote;
+use syn::spanned::Spanned;
+use syn::{parse_macro_input, parse_quote, DeriveInput, Ident, Lifetime, Type, WherePredicate};
+use synstructure::Structure;
+
+mod visitor;
+
+/// Custom derive for `yoke::Yokeable`,
+///
+/// If your struct contains `zerovec::ZeroMap`, then the compiler will not
+/// be able to guarantee the lifetime covariance due to the generic types on
+/// the `ZeroMap` itself. You must add the following attribute in order for
+/// the custom derive to work with `ZeroMap`.
+///
+/// ```rust,ignore
+/// #[derive(Yokeable)]
+/// #[yoke(prove_covariance_manually)]
+/// ```
+///
+/// Beyond this case, if the derive fails to compile due to lifetime issues, it
+/// means that the lifetime is not covariant and `Yokeable` is not safe to implement.
+#[proc_macro_derive(Yokeable, attributes(yoke))]
+pub fn yokeable_derive(input: TokenStream) -> TokenStream {
+ let input = parse_macro_input!(input as DeriveInput);
+ TokenStream::from(yokeable_derive_impl(&input))
+}
+
+fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
+ let tybounds = input
+ .generics
+ .type_params()
+ .map(|ty| {
+ // Strip out param defaults, we don't need them in the impl
+ let mut ty = ty.clone();
+ ty.eq_token = None;
+ ty.default = None;
+ ty
+ })
+ .collect::<Vec<_>>();
+ let typarams = tybounds
+ .iter()
+ .map(|ty| ty.ident.clone())
+ .collect::<Vec<_>>();
+ // We require all type parameters be 'static, otherwise
+ // the Yokeable impl becomes really unweildy to generate safely
+ let static_bounds: Vec<WherePredicate> = typarams
+ .iter()
+ .map(|ty| parse_quote!(#ty: 'static))
+ .collect();
+ let lts = input.generics.lifetimes().count();
+ if lts == 0 {
+ let name = &input.ident;
+ quote! {
+ // This is safe because there are no lifetime parameters.
+ unsafe impl<'a, #(#tybounds),*> yoke::Yokeable<'a> for #name<#(#typarams),*> where #(#static_bounds,)* Self: Sized {
+ type Output = Self;
+ #[inline]
+ fn transform(&self) -> &Self::Output {
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> Self::Output {
+ self
+ }
+ #[inline]
+ unsafe fn make(this: Self::Output) -> Self {
+ this
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output) {
+ f(self)
+ }
+ }
+ }
+ } else {
+ if lts != 1 {
+ return syn::Error::new(
+ input.generics.span(),
+ "derive(Yokeable) cannot have multiple lifetime parameters",
+ )
+ .to_compile_error();
+ }
+ let name = &input.ident;
+ let manual_covariance = input.attrs.iter().any(|a| {
+ if let Ok(i) = a.parse_args::<Ident>() {
+ if i == "prove_covariance_manually" {
+ return true;
+ }
+ }
+ false
+ });
+ if manual_covariance {
+ let mut structure = Structure::new(input);
+ let generics_env = typarams.iter().cloned().collect();
+ let static_bounds: Vec<WherePredicate> = typarams
+ .iter()
+ .map(|ty| parse_quote!(#ty: 'static))
+ .collect();
+ let mut yoke_bounds: Vec<WherePredicate> = vec![];
+ structure.bind_with(|_| synstructure::BindStyle::Move);
+ let owned_body = structure.each_variant(|vi| {
+ vi.construct(|f, i| {
+ let binding = format!("__binding_{i}");
+ let field = Ident::new(&binding, Span::call_site());
+ let fty_static = replace_lifetime(&f.ty, static_lt());
+
+ let (has_ty, has_lt) = visitor::check_type_for_parameters(&f.ty, &generics_env);
+ if has_ty {
+ // For types without type parameters, the compiler can figure out that the field implements
+ // Yokeable on its own. However, if there are type parameters, there may be complex preconditions
+ // to `FieldTy: Yokeable` that need to be satisfied. We get them to be satisfied by requiring
+ // `FieldTy<'static>: Yokeable<FieldTy<'a>>`
+ if has_lt {
+ let fty_a = replace_lifetime(&f.ty, custom_lt("'a"));
+ yoke_bounds.push(
+ parse_quote!(#fty_static: yoke::Yokeable<'a, Output = #fty_a>),
+ );
+ } else {
+ yoke_bounds.push(
+ parse_quote!(#fty_static: yoke::Yokeable<'a, Output = #fty_static>),
+ );
+ }
+ }
+ if has_ty || has_lt {
+ // By calling transform_owned on all fields, we manually prove
+ // that the lifetimes are covariant, since this requirement
+ // must already be true for the type that implements transform_owned().
+ quote! {
+ <#fty_static as yoke::Yokeable<'a>>::transform_owned(#field)
+ }
+ } else {
+ // No nested lifetimes, so nothing to be done
+ quote! { #field }
+ }
+ })
+ });
+ let borrowed_body = structure.each(|binding| {
+ let f = binding.ast();
+ let field = &binding.binding;
+
+ let (has_ty, has_lt) = visitor::check_type_for_parameters(&f.ty, &generics_env);
+
+ if has_ty || has_lt {
+ let fty_static = replace_lifetime(&f.ty, static_lt());
+ let fty_a = replace_lifetime(&f.ty, custom_lt("'a"));
+ // We also must assert that each individual field can `transform()` correctly
+ //
+ // Even though transform_owned() does such an assertion already, CoerceUnsized
+ // can cause type transformations that allow it to succeed where this would fail.
+ // We need to check both.
+ //
+ // https://github.com/unicode-org/icu4x/issues/2928
+ quote! {
+ let _: &#fty_a = &<#fty_static as yoke::Yokeable<'a>>::transform(#field);
+ }
+ } else {
+ // No nested lifetimes, so nothing to be done
+ quote! {}
+ }
+ });
+ return quote! {
+ unsafe impl<'a, #(#tybounds),*> yoke::Yokeable<'a> for #name<'static, #(#typarams),*>
+ where #(#static_bounds,)*
+ #(#yoke_bounds,)* {
+ type Output = #name<'a, #(#typarams),*>;
+ #[inline]
+ fn transform(&'a self) -> &'a Self::Output {
+ // These are just type asserts, we don't need them for anything
+ if false {
+ match self {
+ #borrowed_body
+ }
+ }
+ unsafe {
+ // safety: we have asserted covariance in
+ // transform_owned
+ ::core::mem::transmute(self)
+ }
+ }
+ #[inline]
+ fn transform_owned(self) -> Self::Output {
+ match self { #owned_body }
+ }
+ #[inline]
+ unsafe fn make(this: Self::Output) -> Self {
+ use core::{mem, ptr};
+ // unfortunately Rust doesn't think `mem::transmute` is possible since it's not sure the sizes
+ // are the same
+ debug_assert!(mem::size_of::<Self::Output>() == mem::size_of::<Self>());
+ let ptr: *const Self = (&this as *const Self::Output).cast();
+ #[allow(forgetting_copy_types, clippy::forget_copy, clippy::forget_non_drop)] // This is a noop if the struct is copy, which Clippy doesn't like
+ mem::forget(this);
+ ptr::read(ptr)
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output) {
+ unsafe { f(core::mem::transmute::<&'a mut Self, &'a mut Self::Output>(self)) }
+ }
+ }
+ };
+ }
+ quote! {
+ // This is safe because as long as `transform()` compiles,
+ // we can be sure that `'a` is a covariant lifetime on `Self`
+ //
+ // This will not work for structs involving ZeroMap since
+ // the compiler does not know that ZeroMap is covariant.
+ //
+ // This custom derive can be improved to handle this case when
+ // necessary
+ unsafe impl<'a, #(#tybounds),*> yoke::Yokeable<'a> for #name<'static, #(#typarams),*> where #(#static_bounds,)* {
+ type Output = #name<'a, #(#typarams),*>;
+ #[inline]
+ fn transform(&'a self) -> &'a Self::Output {
+ self
+ }
+ #[inline]
+ fn transform_owned(self) -> Self::Output {
+ self
+ }
+ #[inline]
+ unsafe fn make(this: Self::Output) -> Self {
+ use core::{mem, ptr};
+ // unfortunately Rust doesn't think `mem::transmute` is possible since it's not sure the sizes
+ // are the same
+ debug_assert!(mem::size_of::<Self::Output>() == mem::size_of::<Self>());
+ let ptr: *const Self = (&this as *const Self::Output).cast();
+ #[allow(forgetting_copy_types, clippy::forget_copy, clippy::forget_non_drop)] // This is a noop if the struct is copy, which Clippy doesn't like
+ mem::forget(this);
+ ptr::read(ptr)
+ }
+ #[inline]
+ fn transform_mut<F>(&'a mut self, f: F)
+ where
+ F: 'static + for<'b> FnOnce(&'b mut Self::Output) {
+ unsafe { f(core::mem::transmute::<&'a mut Self, &'a mut Self::Output>(self)) }
+ }
+ }
+ }
+ }
+}
+
+fn static_lt() -> Lifetime {
+ Lifetime::new("'static", Span::call_site())
+}
+
+fn custom_lt(s: &str) -> Lifetime {
+ Lifetime::new(s, Span::call_site())
+}
+
+fn replace_lifetime(x: &Type, lt: Lifetime) -> Type {
+ use syn::fold::Fold;
+ struct ReplaceLifetime(Lifetime);
+
+ impl Fold for ReplaceLifetime {
+ fn fold_lifetime(&mut self, _: Lifetime) -> Lifetime {
+ self.0.clone()
+ }
+ }
+ ReplaceLifetime(lt).fold_type(x.clone())
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/visitor.rs b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/visitor.rs
new file mode 100644
index 0000000..109d041
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/visitor.rs
@@ -0,0 +1,113 @@
+// This file is part of ICU4X. For terms of use, please see the file
+// called LICENSE at the top level of the ICU4X source tree
+// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+
+//! Visitor for determining whether a type has type and non-static lifetime parameters
+
+use std::collections::HashSet;
+use syn::visit::{visit_lifetime, visit_type, visit_type_path, Visit};
+use syn::{Ident, Lifetime, Type, TypePath};
+
+struct TypeVisitor<'a> {
+ /// The type parameters in scope
+ typarams: &'a HashSet<Ident>,
+ /// Whether we found a type parameter
+ found_typarams: bool,
+ /// Whether we found a non-'static lifetime parameter
+ found_lifetimes: bool,
+}
+
+impl<'ast> Visit<'ast> for TypeVisitor<'_> {
+ fn visit_lifetime(&mut self, lt: &'ast Lifetime) {
+ if lt.ident != "static" {
+ self.found_lifetimes = true;
+ }
+ visit_lifetime(self, lt)
+ }
+ fn visit_type_path(&mut self, ty: &'ast TypePath) {
+ // We only need to check ty.path.get_ident() and not ty.qself or any
+ // generics in ty.path because the visitor will eventually visit those
+ // types on its own
+ if let Some(ident) = ty.path.get_ident() {
+ if self.typarams.contains(ident) {
+ self.found_typarams = true;
+ }
+ }
+
+ visit_type_path(self, ty)
+ }
+}
+
+/// Checks if a type has type or lifetime parameters, given the local context of
+/// named type parameters. Returns (has_type_params, has_lifetime_params)
+pub fn check_type_for_parameters(ty: &Type, typarams: &HashSet<Ident>) -> (bool, bool) {
+ let mut visit = TypeVisitor {
+ typarams,
+ found_typarams: false,
+ found_lifetimes: false,
+ };
+ visit_type(&mut visit, ty);
+
+ (visit.found_typarams, visit.found_lifetimes)
+}
+
+#[cfg(test)]
+mod tests {
+ use proc_macro2::Span;
+ use std::collections::HashSet;
+ use syn::{parse_quote, Ident};
+
+ use super::check_type_for_parameters;
+ fn make_typarams(params: &[&str]) -> HashSet<Ident> {
+ params
+ .iter()
+ .map(|x| Ident::new(x, Span::call_site()))
+ .collect()
+ }
+
+ #[test]
+ fn test_simple_type() {
+ let environment = make_typarams(&["T", "U", "V"]);
+
+ let ty = parse_quote!(Foo<'a, T>);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, true));
+
+ let ty = parse_quote!(Foo<T>);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, false));
+
+ let ty = parse_quote!(Foo<'static, T>);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, false));
+
+ let ty = parse_quote!(Foo<'a>);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (false, true));
+
+ let ty = parse_quote!(Foo<'a, Bar<U>, Baz<(V, u8)>>);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, true));
+
+ let ty = parse_quote!(Foo<'a, W>);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (false, true));
+ }
+
+ #[test]
+ fn test_assoc_types() {
+ let environment = make_typarams(&["T"]);
+
+ let ty = parse_quote!(<Foo as SomeTrait<'a, T>>::Output);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, true));
+
+ let ty = parse_quote!(<Foo as SomeTrait<'static, T>>::Output);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, false));
+
+ let ty = parse_quote!(<T as SomeTrait<'static, Foo>>::Output);
+ let check = check_type_for_parameters(&ty, &environment);
+ assert_eq!(check, (true, false));
+ }
+}
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo_vcs_info.json
deleted file mode 100644
index 96cbf55..0000000
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo_vcs_info.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "git": {
- "sha1": "6bd4893cc44c2ca2718de47a119a31cc40045fe5"
- },
- "path_in_vcs": "utils/zerotrie"
-}
\ No newline at end of file
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/.cargo-checksum.json
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/.cargo-checksum.json
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/.cargo-checksum.json
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/.cargo_vcs_info.json
new file mode 100644
index 0000000..1e799ee
--- /dev/null
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/.cargo_vcs_info.json
@@ -0,0 +1,6 @@
+{
+ "git": {
+ "sha1": "e9ab7308efb2fdc0fca96f71106c68f9f5840056"
+ },
+ "path_in_vcs": "utils/zerotrie"
+}
\ No newline at end of file
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.lock b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.lock
similarity index 84%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.lock
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.lock
index 3f4d47b..f79d01c 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.lock
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.lock
@@ -40,9 +40,9 @@
[[package]]
name = "bumpalo"
-version = "3.15.0"
+version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f"
+checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]]
name = "byteorder"
@@ -91,18 +91,18 @@
[[package]]
name = "clap"
-version = "4.4.0"
+version = "4.5.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d"
+checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767"
dependencies = [
"clap_builder",
]
[[package]]
name = "clap_builder"
-version = "4.4.0"
+version = "4.5.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6"
+checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863"
dependencies = [
"anstyle",
"clap_lex",
@@ -110,9 +110,9 @@
[[package]]
name = "clap_lex"
-version = "0.5.1"
+version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
+checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "cobs"
@@ -158,9 +158,9 @@
[[package]]
name = "crossbeam-deque"
-version = "0.8.5"
+version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
+checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
@@ -177,15 +177,15 @@
[[package]]
name = "crossbeam-utils"
-version = "0.8.20"
+version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
+checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crunchy"
-version = "0.2.2"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
+checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "databake"
@@ -223,9 +223,9 @@
[[package]]
name = "either"
-version = "1.13.0"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
+checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d"
[[package]]
name = "embedded-io"
@@ -268,13 +268,13 @@
[[package]]
name = "is-terminal"
-version = "0.4.13"
+version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b"
+checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
dependencies = [
"hermit-abi",
"libc",
- "windows-sys 0.52.0",
+ "windows-sys",
]
[[package]]
@@ -288,39 +288,40 @@
[[package]]
name = "itoa"
-version = "1.0.13"
+version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2"
+checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
[[package]]
name = "js-sys"
-version = "0.3.72"
+version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
+checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
dependencies = [
+ "once_cell",
"wasm-bindgen",
]
[[package]]
name = "libc"
-version = "0.2.164"
+version = "0.2.170"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
+checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
[[package]]
name = "litemap"
-version = "0.7.3"
+version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704"
+checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856"
dependencies = [
"serde",
]
[[package]]
name = "log"
-version = "0.4.22"
+version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
+checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[package]]
name = "memchr"
@@ -339,9 +340,9 @@
[[package]]
name = "once_cell"
-version = "1.20.2"
+version = "1.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
+checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
[[package]]
name = "oorandom"
@@ -385,9 +386,9 @@
[[package]]
name = "postcard"
-version = "1.0.10"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e"
+checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
dependencies = [
"cobs",
"embedded-io 0.4.0",
@@ -406,18 +407,18 @@
[[package]]
name = "proc-macro2"
-version = "1.0.92"
+version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
+checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.37"
+version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
+checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
dependencies = [
"proc-macro2",
]
@@ -533,10 +534,16 @@
]
[[package]]
-name = "ryu"
-version = "1.0.18"
+name = "rustversion"
+version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
+checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
+
+[[package]]
+name = "ryu"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
[[package]]
name = "same-file"
@@ -549,18 +556,18 @@
[[package]]
name = "serde"
-version = "1.0.215"
+version = "1.0.218"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
+checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.215"
+version = "1.0.218"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
+checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
dependencies = [
"proc-macro2",
"quote",
@@ -569,9 +576,9 @@
[[package]]
name = "serde_json"
-version = "1.0.133"
+version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
+checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
dependencies = [
"itoa",
"memchr",
@@ -587,9 +594,9 @@
[[package]]
name = "syn"
-version = "2.0.89"
+version = "2.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
+checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
dependencies = [
"proc-macro2",
"quote",
@@ -619,9 +626,9 @@
[[package]]
name = "unicode-ident"
-version = "1.0.14"
+version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
+checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
[[package]]
name = "walkdir"
@@ -641,24 +648,24 @@
[[package]]
name = "wasm-bindgen"
-version = "0.2.95"
+version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
+checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
+ "rustversion",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.95"
+version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
+checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
- "once_cell",
"proc-macro2",
"quote",
"syn",
@@ -667,9 +674,9 @@
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.95"
+version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
+checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -677,9 +684,9 @@
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.95"
+version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
+checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
@@ -690,15 +697,18 @@
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.95"
+version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
+checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
+dependencies = [
+ "unicode-ident",
+]
[[package]]
name = "web-sys"
-version = "0.3.72"
+version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112"
+checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -710,16 +720,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
- "windows-sys 0.59.0",
-]
-
-[[package]]
-name = "windows-sys"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
-dependencies = [
- "windows-targets",
+ "windows-sys",
]
[[package]]
@@ -797,9 +798,9 @@
[[package]]
name = "yoke"
-version = "0.7.5"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
+checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc"
dependencies = [
"stable_deref_trait",
"yoke-derive",
@@ -808,9 +809,9 @@
[[package]]
name = "yoke-derive"
-version = "0.7.5"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
+checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
dependencies = [
"proc-macro2",
"quote",
@@ -841,18 +842,18 @@
[[package]]
name = "zerofrom"
-version = "0.1.4"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55"
+checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
-version = "0.1.4"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
+checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
dependencies = [
"proc-macro2",
"quote",
@@ -862,7 +863,7 @@
[[package]]
name = "zerotrie"
-version = "0.2.0"
+version = "0.2.1"
dependencies = [
"bincode",
"criterion",
@@ -882,9 +883,9 @@
[[package]]
name = "zerovec"
-version = "0.11.0"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b622856b789971a6fe0442b69f3a2d7ac949005c4c8586b2c4ef09cc5182f2b"
+checksum = "94e62113720e311984f461c56b00457ae9981c0bc7859d22306cc2ae2f95571c"
dependencies = [
"databake",
"serde",
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.toml
similarity index 94%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.toml
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.toml
index a359ba8..cfa15aa 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.toml
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.toml
@@ -11,9 +11,9 @@
[package]
edition = "2021"
-rust-version = "1.71.1"
+rust-version = "1.81"
name = "zerotrie"
-version = "0.2.0"
+version = "0.2.1"
authors = ["The ICU4X Project Developers"]
build = false
include = [
@@ -26,6 +26,7 @@
"LICENSE",
"README.md",
]
+autolib = false
autobins = false
autoexamples = false
autotests = false
@@ -37,12 +38,30 @@
license = "Unicode-3.0"
repository = "https://github.com/unicode-org/icu4x"
-[package.metadata.cargo-all-features]
-denylist = ["bench"]
-
[package.metadata.docs.rs]
all-features = true
+[features]
+alloc = []
+databake = [
+ "dep:databake",
+ "zerovec?/databake",
+]
+default = []
+litemap = [
+ "dep:litemap",
+ "alloc",
+]
+serde = [
+ "dep:serde",
+ "dep:litemap",
+ "alloc",
+ "litemap/serde",
+ "zerovec?/serde",
+]
+yoke = ["dep:yoke"]
+zerofrom = ["dep:zerofrom"]
+
[lib]
name = "zerotrie"
path = "src/lib.rs"
@@ -115,7 +134,7 @@
default-features = false
[dependencies.yoke]
-version = "0.7.5"
+version = "0.8.0"
features = ["derive"]
optional = true
default-features = false
@@ -126,7 +145,7 @@
default-features = false
[dependencies.zerovec]
-version = "0.11.0"
+version = "0.11.1"
optional = true
default-features = false
@@ -134,7 +153,7 @@
version = "1.3.1"
[dev-dependencies.postcard]
-version = "1.0.1"
+version = "1.0.3"
features = ["alloc"]
default-features = false
@@ -154,27 +173,5 @@
[dev-dependencies.serde_json]
version = "1.0.45"
-[features]
-alloc = []
-bench = ["litemap"]
-databake = [
- "dep:databake",
- "zerovec?/databake",
-]
-default = []
-litemap = [
- "dep:litemap",
- "alloc",
-]
-serde = [
- "dep:serde",
- "dep:litemap",
- "alloc",
- "litemap/serde",
- "zerovec?/serde",
-]
-yoke = ["dep:yoke"]
-zerofrom = ["dep:zerofrom"]
-
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies.criterion]
version = "0.5.0"
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.toml.orig
similarity index 92%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.toml.orig
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.toml.orig
index acd1f24..34f3044 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/Cargo.toml.orig
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/Cargo.toml.orig
@@ -5,7 +5,7 @@
[package]
name = "zerotrie"
description = "A data structure that efficiently maps strings to integers"
-version = "0.2.0"
+version = "0.2.1"
authors.workspace = true
categories.workspace = true
@@ -19,10 +19,6 @@
[package.metadata.docs.rs]
all-features = true
-[package.metadata.cargo-all-features]
-# Bench feature gets tested separately and is only relevant for CI
-denylist = ["bench"]
-
[dependencies]
databake = { workspace = true, features = ["derive"], optional = true }
displaydoc = { workspace = true }
@@ -54,7 +50,6 @@
[features]
default = []
-bench = ["litemap"]
alloc = []
databake = ["dep:databake", "zerovec?/databake"]
litemap = ["dep:litemap", "alloc"]
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/LICENSE
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/LICENSE
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/README.md b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/README.md
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/README.md
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/README.md
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/benches/overview.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/benches/overview.rs
similarity index 95%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/benches/overview.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/benches/overview.rs
index 7c47d509..be17e60 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/benches/overview.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/benches/overview.rs
@@ -4,14 +4,11 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use litemap::LiteMap;
-#[cfg(feature = "bench")]
use std::collections::HashMap;
use zerotrie::ZeroTrieExtendedCapacity;
use zerotrie::ZeroTriePerfectHash;
use zerotrie::ZeroTrieSimpleAscii;
-#[cfg(feature = "bench")]
use zerovec::ZeroHashMap;
-#[cfg(feature = "bench")]
use zerovec::ZeroMap;
mod testdata {
@@ -55,7 +52,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("ZeroMap/u32", |b| {
let zm: ZeroMap<[u8], u32> = data.iter().map(|(a, b)| (*a, *b as u32)).collect();
b.iter(|| {
@@ -66,7 +62,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("ZeroMap/u8", |b| {
let zm: ZeroMap<[u8], u8> = data.iter().map(|(k, v)| (*k, *v as u8)).collect();
b.iter(|| {
@@ -77,7 +72,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("HashMap", |b| {
let hm: HashMap<&[u8], usize> = data.iter().copied().collect();
b.iter(|| {
@@ -88,7 +82,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("ZeroHashMap/u8", |b| {
let zhm: ZeroHashMap<[u8], u8> = data.iter().map(|(k, v)| (*k, *v as u8)).collect();
b.iter(|| {
@@ -153,7 +146,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("ZeroMap/u32", |b| {
let zm: ZeroMap<[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
b.iter(|| {
@@ -164,7 +156,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("ZeroMap/u8", |b| {
let zm: ZeroMap<[u8], u8> = litemap.iter().map(|(k, v)| (*k, *v as u8)).collect();
b.iter(|| {
@@ -175,7 +166,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("HashMap", |b| {
let hm: HashMap<&[u8], u32> = litemap.iter().map(|(a, b)| (*a, *b as u32)).collect();
b.iter(|| {
@@ -186,7 +176,6 @@
});
});
- #[cfg(feature = "bench")]
g.bench_function("ZeroHashMap/u8", |b| {
let zhm: ZeroHashMap<[u8], u8> = litemap.iter().map(|(k, v)| (*k, *v as u8)).collect();
b.iter(|| {
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/examples/first_weekday_for_region.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/examples/first_weekday_for_region.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/examples/first_weekday_for_region.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/examples/first_weekday_for_region.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/branch_meta.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/branch_meta.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/branch_meta.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/branch_meta.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/bytestr.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/bytestr.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/bytestr.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/bytestr.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/builder.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/builder.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/builder.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/builder.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/mod.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/mod.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/mod.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/mod.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/store.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/store.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/store.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/store.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/litemap.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/litemap.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/litemap.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/litemap.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/mod.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/mod.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/mod.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/mod.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/builder.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/builder.rs
similarity index 98%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/builder.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/builder.rs
index 02dd062..b42ce80 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/builder.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/builder.rs
@@ -103,7 +103,7 @@
.iter()
.map(|(k, v)| (k.as_ref(), *v))
.collect::<Vec<(&[u8], usize)>>();
- items.sort_by(|a, b| cmp_keys_values(&options, *a, *b));
+ items.sort_by(|a, b| cmp_keys_values(options, *a, *b));
let ascii_str_slice = items.as_slice();
let byte_str_slice = ByteStr::from_byte_slice_with_value(ascii_str_slice);
Self::from_sorted_tuple_slice_impl(byte_str_slice, options)
@@ -123,7 +123,7 @@
if matches!(options.case_sensitivity, CaseSensitivity::IgnoreCase) {
// We need to re-sort the items with our custom comparator.
items.to_mut().sort_by(|a, b| {
- cmp_keys_values(&options, (a.0.as_bytes(), a.1), (b.0.as_bytes(), b.1))
+ cmp_keys_values(options, (a.0.as_bytes(), a.1), (b.0.as_bytes(), b.1))
});
}
Self::from_sorted_tuple_slice_impl(&items, options)
@@ -136,7 +136,7 @@
) -> Result<Self, ZeroTrieBuildError> {
for ab in items.windows(2) {
debug_assert!(cmp_keys_values(
- &options,
+ options,
(ab[0].0.as_bytes(), ab[0].1),
(ab[1].0.as_bytes(), ab[1].1)
)
@@ -403,7 +403,7 @@
}
fn cmp_keys_values(
- options: &ZeroTrieBuilderOptions,
+ options: ZeroTrieBuilderOptions,
a: (&[u8], usize),
b: (&[u8], usize),
) -> Ordering {
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/mod.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/mod.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/mod.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/mod.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/store.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/store.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/store.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/store.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/builder.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/builder.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/builder.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/builder.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/cached_owned.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/cached_owned.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/cached_owned.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/cached_owned.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/mod.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/mod.rs
similarity index 99%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/mod.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/mod.rs
index 6783fdb..858ea03 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/mod.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/mod.rs
@@ -238,8 +238,9 @@
pub fn as_bytes(&self) -> &[u8] {
self.0.as_ref()
}
+
#[cfg(all(feature = "alloc", test))]
- pub fn check(&self) -> Result<(), (&'static str, u8)> {
+ pub(crate) fn check(&self) -> Result<(), (&'static str, u8)> {
use alloc::vec;
let len = self.num_items();
let mut seen = vec![false; len];
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/cursor.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/cursor.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/cursor.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/cursor.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/error.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/error.rs
similarity index 94%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/error.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/error.rs
index 42dbc8b..9ef5b86e 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/error.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/error.rs
@@ -21,3 +21,5 @@
#[displaydoc("Mixed-case data added to case-insensitive trie")]
MixedCase,
}
+
+impl core::error::Error for ZeroTrieBuildError {}
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/helpers.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/helpers.rs
similarity index 79%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/helpers.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/helpers.rs
index 0d24f22..33440b9 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/helpers.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/helpers.rs
@@ -3,9 +3,6 @@
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
pub(crate) trait MaybeSplitAt<T> {
- /// Like slice::split_at but returns an Option instead of panicking
- /// if the index is out of range.
- fn maybe_split_at(&self, mid: usize) -> Option<(&Self, &Self)>;
/// Like slice::split_at but debug-panics and returns an empty second slice
/// if the index is out of range.
fn debug_split_at(&self, mid: usize) -> (&Self, &Self);
@@ -13,25 +10,11 @@
impl<T> MaybeSplitAt<T> for [T] {
#[inline]
- fn maybe_split_at(&self, mid: usize) -> Option<(&Self, &Self)> {
- if mid > self.len() {
- None
- } else {
- // Note: We're trusting the compiler to inline this and remove the assertion
- // hiding on the top of slice::split_at: `assert(mid <= self.len())`
- Some(self.split_at(mid))
- }
- }
- #[inline]
fn debug_split_at(&self, mid: usize) -> (&Self, &Self) {
- if mid > self.len() {
- debug_assert!(false, "debug_split_at: index expected to be in range");
+ self.split_at_checked(mid).unwrap_or_else(|| {
+ debug_assert!(false, "debug_split_at: {mid} expected to be in range");
(self, &[])
- } else {
- // Note: We're trusting the compiler to inline this and remove the assertion
- // hiding on the top of slice::split_at: `assert(mid <= self.len())`
- self.split_at(mid)
- }
+ })
}
}
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/lib.rs
similarity index 95%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/lib.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/lib.rs
index 0f6e05f..a5c9e3d 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/lib.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/lib.rs
@@ -35,7 +35,7 @@
//! [`BTreeMap`]: alloc::collections::BTreeMap
// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
-#![cfg_attr(not(test), no_std)]
+#![cfg_attr(not(any(test, doc)), no_std)]
#![cfg_attr(
not(test),
deny(
@@ -45,7 +45,7 @@
clippy::expect_used,
// clippy::panic,
clippy::exhaustive_structs,
- clippy::exhaustive_enums,
+ clippy::exhaustive_enums, clippy::trivially_copy_pass_by_ref,
missing_debug_implementations,
)
)]
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/options.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/options.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/options.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/options.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/reader.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/reader.rs
similarity index 98%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/reader.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/reader.rs
index 3c69f84..4d3dd005 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/reader.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/reader.rs
@@ -323,7 +323,7 @@
if matches!(byte_type, NodeType::Ascii) {
let is_match = if matches!(T::OPTIONS.case_sensitivity, CaseSensitivity::IgnoreCase)
{
- b.to_ascii_lowercase() == c.to_ascii_lowercase()
+ b.eq_ignore_ascii_case(c)
} else {
b == c
};
@@ -345,7 +345,7 @@
{
let (trie_span, ascii_span);
(trie_span, trie) = trie.debug_split_at(x);
- (ascii_span, ascii) = ascii.maybe_split_at(x)?;
+ (ascii_span, ascii) = ascii.split_at_checked(x)?;
if trie_span == ascii_span {
// Matched a byte span
continue;
@@ -446,7 +446,7 @@
NodeType::Ascii => {
let is_match = if matches!(T::OPTIONS.case_sensitivity, CaseSensitivity::IgnoreCase)
{
- b.to_ascii_lowercase() == c.to_ascii_lowercase()
+ b.eq_ignore_ascii_case(&c)
} else {
*b == c
};
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/serde.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/serde.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/serde.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/serde.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/varint.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/varint.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/varint.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/varint.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/zerotrie.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/zerotrie.rs
similarity index 93%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/zerotrie.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/zerotrie.rs
index 13fbeb7f..a0320f9 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/zerotrie.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/zerotrie.rs
@@ -119,6 +119,15 @@
pub store: Store,
}
+impl<Store: ?Sized> ZeroTrieSimpleAscii<Store> {
+ fn transparent_ref_from_store(s: &Store) -> &Self {
+ unsafe {
+ // Safety: Self is transparent over Store
+ core::mem::transmute(s)
+ }
+ }
+}
+
impl<Store> ZeroTrieSimpleAscii<Store> {
/// Wrap this specific ZeroTrie variant into a ZeroTrie.
#[inline]
@@ -177,6 +186,15 @@
pub store: Store,
}
+impl<Store: ?Sized> ZeroAsciiIgnoreCaseTrie<Store> {
+ fn transparent_ref_from_store(s: &Store) -> &Self {
+ unsafe {
+ // Safety: Self is transparent over Store
+ core::mem::transmute(s)
+ }
+ }
+}
+
// Note: ZeroAsciiIgnoreCaseTrie is not a variant of ZeroTrie so there is no `into_zerotrie`
/// A data structure that compactly maps from byte strings to integers.
@@ -213,6 +231,15 @@
pub store: Store,
}
+impl<Store: ?Sized> ZeroTriePerfectHash<Store> {
+ fn transparent_ref_from_store(s: &Store) -> &Self {
+ unsafe {
+ // Safety: Self is transparent over Store
+ core::mem::transmute(s)
+ }
+ }
+}
+
impl<Store> ZeroTriePerfectHash<Store> {
/// Wrap this specific ZeroTrie variant into a ZeroTrie.
#[inline]
@@ -234,6 +261,15 @@
pub store: Store,
}
+impl<Store: ?Sized> ZeroTrieExtendedCapacity<Store> {
+ fn transparent_ref_from_store(s: &Store) -> &Self {
+ unsafe {
+ // Safety: Self is transparent over Store
+ core::mem::transmute(s)
+ }
+ }
+}
+
impl<Store> ZeroTrieExtendedCapacity<Store> {
/// Wrap this specific ZeroTrie variant into a ZeroTrie.
#[inline]
@@ -387,8 +423,7 @@
/// If the bytes are not a valid trie, unexpected behavior may occur.
#[inline]
pub fn from_bytes(trie: &[u8]) -> &Self {
- // Safety: Self is repr(transparent) over [u8]
- unsafe { core::mem::transmute(trie) }
+ Self::transparent_ref_from_store(trie)
}
}
#[cfg(feature = "alloc")]
@@ -598,7 +633,16 @@
}
}
// TODO(#2778): Auto-derive these impls based on the repr(transparent).
- // Safety: $name is repr(transparent) over S, a VarULE
+ //
+ // Safety (based on the safety checklist on the VarULE trait):
+ // 1. `$name` does not include any uninitialized or padding bytes as it is `repr(transparent)`
+ // over a `VarULE` type, `Store`, as evidenced by the existence of `transparent_ref_from_store()`
+ // 2. `$name` is aligned to 1 byte for the same reason
+ // 3. The impl of `validate_bytes()` returns an error if any byte is not valid (passed down to `VarULE` impl of `Store`)
+ // 4. The impl of `validate_bytes()` returns an error if the slice cannot be used in its entirety (passed down to `VarULE` impl of `Store`)
+ // 5. The impl of `from_bytes_unchecked()` returns a reference to the same data.
+ // 6. `parse_bytes()` is left to its default impl
+ // 7. byte equality is semantic equality
#[cfg(feature = "zerovec")]
unsafe impl<Store> zerovec::ule::VarULE for $name<Store>
where
@@ -610,7 +654,8 @@
}
#[inline]
unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self {
- core::mem::transmute(Store::from_bytes_unchecked(bytes))
+ // Safety: we can pass down the validity invariant to Store
+ Self::transparent_ref_from_store(Store::from_bytes_unchecked(bytes))
}
}
#[cfg(feature = "zerofrom")]
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/asciitrie_test.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/asciitrie_test.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/asciitrie_test.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/asciitrie_test.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/builder_test.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/builder_test.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/builder_test.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/builder_test.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/data/data.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/data/data.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/data/data.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/data/data.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/derive_test.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/derive_test.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/derive_test.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/derive_test.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/ignorecase_test.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/ignorecase_test.rs
similarity index 100%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/ignorecase_test.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/ignorecase_test.rs
diff --git a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/locale_aux_test.rs b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/locale_aux_test.rs
similarity index 97%
rename from third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/locale_aux_test.rs
rename to third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/locale_aux_test.rs
index 0959309..10b61071 100644
--- a/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/tests/locale_aux_test.rs
+++ b/third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/tests/locale_aux_test.rs
@@ -55,7 +55,7 @@
8445
);
- let total_str_len = litemap.iter_keys().map(|k| k.len()).sum::<usize>();
+ let total_str_len = litemap.keys().map(|k| k.len()).sum::<usize>();
assert_eq!(total_str_len, 8115);
// Lookup table size:
@@ -118,7 +118,7 @@
let trie = ZeroTriePerfectHash::try_from(&litemap).unwrap();
total_perfecthash_len += trie.byte_len();
- for k in litemap.iter_keys() {
+ for k in litemap.keys() {
unique_locales.insert(k.clone());
}
diff --git a/third_party/rust/chromium_crates_io/vet_config.toml.hbs b/third_party/rust/chromium_crates_io/vet_config.toml.hbs
index 7b476ac..c993bb69 100644
--- a/third_party/rust/chromium_crates_io/vet_config.toml.hbs
+++ b/third_party/rust/chromium_crates_io/vet_config.toml.hbs
@@ -343,19 +343,6 @@
https://crbug.com/366411886
"""
-[[exemptions.yoke-derive]]
-version = "0.7.5"
-criteria = ["safe-to-deploy", "ub-risk-2"]
-notes = """
-Requires unsafe review audit. Unsafe code is either authored or reviewed by a
-crabal member, but a formal audit is yet to be performed.
-
-Part of Google-co-maintained ICU4X project.
-
-
-https://crbug.com/366411886
-"""
-
[[exemptions.zerocopy]]
version = "0.7.35"
criteria = ["safe-to-deploy", "crypto-safe", "ub-risk-2"]
diff --git a/third_party/rust/yoke/v0_8/BUILD.gn b/third_party/rust/yoke/v0_8/BUILD.gn
new file mode 100644
index 0000000..5bf80b2
--- /dev/null
+++ b/third_party/rust/yoke/v0_8/BUILD.gn
@@ -0,0 +1,60 @@
+# Copyright 2023 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by
+# tools/crates/gnrt.
+# Do not edit!
+
+import("//build/rust/cargo_crate.gni")
+
+cargo_crate("lib") {
+ crate_name = "yoke"
+ epoch = "0.8"
+ crate_type = "rlib"
+ crate_root =
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/lib.rs"
+ sources = [
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/cartable_ptr.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/either.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/erased.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/kinda_sorta_dangling.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/lib.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/macro_impls.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yoke.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/yokeable.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/src/zero_from.rs",
+ ]
+ inputs = []
+
+ build_native_rust_unit_tests = false
+ edition = "2021"
+ cargo_pkg_version = "0.8.0"
+ cargo_pkg_authors = "Manish Goregaokar <manishsmail@gmail.com>"
+ cargo_pkg_name = "yoke"
+ cargo_pkg_description = "Abstraction allowing borrowed data to be carried along with the backing data it borrows from"
+ library_configs -= [ "//build/config/coverage:default_coverage" ]
+ library_configs -= [ "//build/config/compiler:chromium_code" ]
+ library_configs += [ "//build/config/compiler:no_chromium_code" ]
+ executable_configs -= [ "//build/config/compiler:chromium_code" ]
+ executable_configs += [ "//build/config/compiler:no_chromium_code" ]
+ proc_macro_configs -= [ "//build/config/compiler:chromium_code" ]
+ proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ]
+ deps = [
+ "//third_party/rust/stable_deref_trait/v1:lib",
+ "//third_party/rust/yoke_derive/v0_8:lib",
+ "//third_party/rust/zerofrom/v0_1:lib",
+ ]
+ features = [
+ "derive",
+ "zerofrom",
+ ]
+ rustflags = [
+ "--cap-lints=allow", # Suppress all warnings in crates.io crates
+ ]
+
+ # Only for usage from third-party crates. Add the crate to
+ # //third_party/rust/chromium_crates_io/Cargo.toml to use
+ # it from first-party code.
+ visibility = [ "//third_party/rust/*" ]
+}
diff --git a/third_party/rust/yoke/v0_8/README.chromium b/third_party/rust/yoke/v0_8/README.chromium
new file mode 100644
index 0000000..85873af
--- /dev/null
+++ b/third_party/rust/yoke/v0_8/README.chromium
@@ -0,0 +1,10 @@
+Name: yoke
+URL: https://crates.io/crates/yoke
+Version: 0.8.0
+Revision: f4290a877dfcb0f87cad6de4abdd65f0cbb33c9c
+License: Unicode-3.0
+License File: //third_party/rust/chromium_crates_io/vendor/yoke-0.8.0/LICENSE
+Shipped: yes
+Security Critical: yes
+
+Description: Abstraction allowing borrowed data to be carried along with the backing data it borrows from
diff --git a/third_party/rust/yoke_derive/v0_8/BUILD.gn b/third_party/rust/yoke_derive/v0_8/BUILD.gn
new file mode 100644
index 0000000..5316c8f
--- /dev/null
+++ b/third_party/rust/yoke_derive/v0_8/BUILD.gn
@@ -0,0 +1,49 @@
+# Copyright 2023 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by
+# tools/crates/gnrt.
+# Do not edit!
+
+import("//build/rust/cargo_crate.gni")
+
+cargo_crate("lib") {
+ crate_name = "yoke_derive"
+ epoch = "0.8"
+ crate_type = "proc-macro"
+ crate_root = "//third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/lib.rs"
+ sources = [
+ "//third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/lib.rs",
+ "//third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/src/visitor.rs",
+ ]
+ inputs = []
+
+ build_native_rust_unit_tests = false
+ edition = "2021"
+ cargo_pkg_version = "0.8.0"
+ cargo_pkg_authors = "Manish Goregaokar <manishsmail@gmail.com>"
+ cargo_pkg_name = "yoke-derive"
+ cargo_pkg_description = "Custom derive for the yoke crate"
+ library_configs -= [ "//build/config/coverage:default_coverage" ]
+ library_configs -= [ "//build/config/compiler:chromium_code" ]
+ library_configs += [ "//build/config/compiler:no_chromium_code" ]
+ executable_configs -= [ "//build/config/compiler:chromium_code" ]
+ executable_configs += [ "//build/config/compiler:no_chromium_code" ]
+ proc_macro_configs -= [ "//build/config/compiler:chromium_code" ]
+ proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ]
+ deps = [
+ "//third_party/rust/proc_macro2/v1:lib",
+ "//third_party/rust/quote/v1:lib",
+ "//third_party/rust/syn/v2:lib",
+ "//third_party/rust/synstructure/v0_13:lib",
+ ]
+ rustflags = [
+ "--cap-lints=allow", # Suppress all warnings in crates.io crates
+ ]
+
+ # Only for usage from third-party crates. Add the crate to
+ # //third_party/rust/chromium_crates_io/Cargo.toml to use
+ # it from first-party code.
+ visibility = [ "//third_party/rust/*" ]
+}
diff --git a/third_party/rust/yoke_derive/v0_8/README.chromium b/third_party/rust/yoke_derive/v0_8/README.chromium
new file mode 100644
index 0000000..a38a6ec
--- /dev/null
+++ b/third_party/rust/yoke_derive/v0_8/README.chromium
@@ -0,0 +1,10 @@
+Name: yoke-derive
+URL: https://crates.io/crates/yoke-derive
+Version: 0.8.0
+Revision: f4290a877dfcb0f87cad6de4abdd65f0cbb33c9c
+License: Unicode-3.0
+License File: //third_party/rust/chromium_crates_io/vendor/yoke-derive-0.8.0/LICENSE
+Shipped: yes
+Security Critical: yes
+
+Description: Custom derive for the yoke crate
diff --git a/third_party/rust/zerotrie/v0_2/BUILD.gn b/third_party/rust/zerotrie/v0_2/BUILD.gn
index 2ff33c4b..2a662b4 100644
--- a/third_party/rust/zerotrie/v0_2/BUILD.gn
+++ b/third_party/rust/zerotrie/v0_2/BUILD.gn
@@ -13,36 +13,36 @@
epoch = "0.2"
crate_type = "rlib"
crate_root =
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/lib.rs"
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/lib.rs"
sources = [
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/branch_meta.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/bytestr.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/builder.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/mod.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/konst/store.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/litemap.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/mod.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/builder.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/mod.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/builder/nonconst/store.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/builder.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/cached_owned.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/byte_phf/mod.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/cursor.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/error.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/helpers.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/lib.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/options.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/reader.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/serde.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/varint.rs",
- "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/src/zerotrie.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/branch_meta.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/bytestr.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/builder.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/mod.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/konst/store.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/litemap.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/mod.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/builder.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/mod.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/builder/nonconst/store.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/builder.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/cached_owned.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/byte_phf/mod.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/cursor.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/error.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/helpers.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/lib.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/options.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/reader.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/serde.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/varint.rs",
+ "//third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/src/zerotrie.rs",
]
inputs = []
build_native_rust_unit_tests = false
edition = "2021"
- cargo_pkg_version = "0.2.0"
+ cargo_pkg_version = "0.2.1"
cargo_pkg_authors = "The ICU4X Project Developers"
cargo_pkg_name = "zerotrie"
cargo_pkg_description =
@@ -56,7 +56,7 @@
proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
"//third_party/rust/displaydoc/v0_2:lib",
- "//third_party/rust/yoke/v0_7:lib",
+ "//third_party/rust/yoke/v0_8:lib",
"//third_party/rust/zerofrom/v0_1:lib",
]
features = [
diff --git a/third_party/rust/zerotrie/v0_2/README.chromium b/third_party/rust/zerotrie/v0_2/README.chromium
index ab0f6a1..04b1dc4 100644
--- a/third_party/rust/zerotrie/v0_2/README.chromium
+++ b/third_party/rust/zerotrie/v0_2/README.chromium
@@ -1,9 +1,9 @@
Name: zerotrie
URL: https://crates.io/crates/zerotrie
-Version: 0.2.0
-Revision: 6bd4893cc44c2ca2718de47a119a31cc40045fe5
+Version: 0.2.1
+Revision: e9ab7308efb2fdc0fca96f71106c68f9f5840056
License: Unicode-3.0
-License File: //third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.0/LICENSE
+License File: //third_party/rust/chromium_crates_io/vendor/zerotrie-0.2.1/LICENSE
Shipped: yes
Security Critical: yes