summaryrefslogtreecommitdiffstats
path: root/vendor/yoke-derive
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/yoke-derive')
-rw-r--r--vendor/yoke-derive/.cargo-checksum.json2
-rw-r--r--vendor/yoke-derive/Cargo.lock87
-rw-r--r--vendor/yoke-derive/Cargo.toml13
-rw-r--r--vendor/yoke-derive/src/lib.rs55
4 files changed, 57 insertions, 100 deletions
diff --git a/vendor/yoke-derive/.cargo-checksum.json b/vendor/yoke-derive/.cargo-checksum.json
index 00b384ec1..5ab332567 100644
--- a/vendor/yoke-derive/.cargo-checksum.json
+++ b/vendor/yoke-derive/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.lock":"749614197321ed7a12f39f677ac7ff5f47b38bd0b610b0448d31eb0acbbfad2d","Cargo.toml":"efb71924dd343a2bc1c174a5068b9178f96d63967d32b0668d27cdc5c3e53332","LICENSE":"4ad7541d66a407234e2c84902124cef325c29f3e966353efdb800bedb8b8da21","README.md":"a386dfc08e98106071c34adf2cdfea6a60c5a1d71ca9c9ed383a4922148d14d7","examples/yoke_derive.rs":"787ad9872040733c243ec81e67e0b9651937d4e01670b6f050c13e82f1c24a4e","src/lib.rs":"f2fd1a01134d82d34c67539929ad7119f29795b719b534309ef39cbb0b2bb4de","src/visitor.rs":"24545c1e81fd35c1d2bd38a1c8d1e684dd08faed4d10d75b103c371df4446c21"},"package":"1346e4cd025ae818b88566eac7eb65ab33a994ea55f355c86889af2e7e56b14e"} \ No newline at end of file
+{"files":{"Cargo.lock":"745a4d99005483f6b9b4eae8db5ea6b260c1913df23ce26d27ad8885c2707003","Cargo.toml":"e4302428531ee62c223811af40a8a73f8c3e8b9d2da51c83b97d1c80a442f69d","LICENSE":"4ad7541d66a407234e2c84902124cef325c29f3e966353efdb800bedb8b8da21","README.md":"a386dfc08e98106071c34adf2cdfea6a60c5a1d71ca9c9ed383a4922148d14d7","examples/yoke_derive.rs":"787ad9872040733c243ec81e67e0b9651937d4e01670b6f050c13e82f1c24a4e","src/lib.rs":"a320049225282da281b8b5fdb2513f8e4bf81b6b784a21dc8c2bd0f53baed85f","src/visitor.rs":"24545c1e81fd35c1d2bd38a1c8d1e684dd08faed4d10d75b103c371df4446c21"},"package":"ca800d73d6b7a7ee54f2608205c98b549fca71c9500c1abcb3abdc7708b4a8cb"} \ No newline at end of file
diff --git a/vendor/yoke-derive/Cargo.lock b/vendor/yoke-derive/Cargo.lock
index 2822aee8f..6ee02cebf 100644
--- a/vendor/yoke-derive/Cargo.lock
+++ b/vendor/yoke-derive/Cargo.lock
@@ -4,39 +4,27 @@ version = 3
[[package]]
name = "proc-macro2"
-version = "1.0.47"
+version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
+checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.21"
+version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
+checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
dependencies = [
"proc-macro2",
]
[[package]]
-name = "serde"
-version = "1.0.145"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
-
-[[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 = "1.0.103"
+version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
+checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
dependencies = [
"proc-macro2",
"quote",
@@ -57,9 +45,9 @@ dependencies = [
[[package]]
name = "unicode-ident"
-version = "1.0.5"
+version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
+checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "unicode-xid"
@@ -68,68 +56,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
-name = "yoke"
-version = "0.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fe1d55ca72c32d573bfbd5cb2f0ca65a497854c44762957a6d3da96041a5184"
-dependencies = [
- "serde",
- "stable_deref_trait",
- "yoke-derive 0.6.0",
- "zerofrom",
-]
-
-[[package]]
-name = "yoke-derive"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58c2c5bb7c929b85c1b9ec69091b0d835f0878b4fd9eb67973b25936e06c4374"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "synstructure",
-]
-
-[[package]]
name = "yoke-derive"
-version = "0.6.1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "synstructure",
- "yoke",
- "zerovec",
-]
-
-[[package]]
-name = "zerofrom"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "79e9355fccf72b04b7deaa99ce7a0f6630530acf34045391b74460fcd714de54"
-dependencies = [
- "zerofrom-derive",
-]
-
-[[package]]
-name = "zerofrom-derive"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8785f47d6062c1932866147f91297286a9f350b3070e9d9f0b6078e37d623c1a"
+version = "0.7.0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
-
-[[package]]
-name = "zerovec"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9d919a74c17749ccb17beaf6405562e413cd94e98ba52ca1e64bbe7eefbd8b8"
-dependencies = [
- "yoke",
- "zerofrom",
-]
diff --git a/vendor/yoke-derive/Cargo.toml b/vendor/yoke-derive/Cargo.toml
index 4d1eedac9..85e25ffa0 100644
--- a/vendor/yoke-derive/Cargo.toml
+++ b/vendor/yoke-derive/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "yoke-derive"
-version = "0.6.1"
+version = "0.7.0"
authors = ["Manish Goregaokar <manishsmail@gmail.com>"]
description = "Custom derive for the yoke crate"
keywords = [
@@ -32,6 +32,9 @@ license = "Unicode-DFS-2016"
repository = "https://github.com/unicode-org/icu4x"
resolver = "2"
+[package.metadata.workspaces]
+independent = true
+
[lib]
path = "src/lib.rs"
proc_macro = true
@@ -52,10 +55,4 @@ features = [
[dependencies.synstructure]
version = "0.12.4"
-[dev-dependencies.yoke]
-version = "0.6.0"
-features = ["derive"]
-
-[dev-dependencies.zerovec]
-version = "0.9"
-features = ["yoke"]
+[dev-dependencies]
diff --git a/vendor/yoke-derive/src/lib.rs b/vendor/yoke-derive/src/lib.rs
index 615669d84..4c53bef68 100644
--- a/vendor/yoke-derive/src/lib.rs
+++ b/vendor/yoke-derive/src/lib.rs
@@ -81,8 +81,6 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
f(self)
}
}
- // This is safe because there are no lifetime parameters.
- unsafe impl<'a, #(#tybounds),*> yoke::IsCovariant<'a> for #name<#(#typarams),*> where #(#static_bounds),* {}
}
} else {
if lts != 1 {
@@ -110,11 +108,11 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
.collect();
let mut yoke_bounds: Vec<WherePredicate> = vec![];
structure.bind_with(|_| synstructure::BindStyle::Move);
- let body = structure.each_variant(|vi| {
+ 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 = replace_lifetime(&f.ty, static_lt());
+ 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 {
@@ -123,11 +121,14 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
// 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 a_ty = replace_lifetime(&f.ty, custom_lt("'a"));
- yoke_bounds
- .push(parse_quote!(#fty: yoke::Yokeable<'a, Output = #a_ty>));
+ 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: yoke::Yokeable<'a, Output = #fty>));
+ yoke_bounds.push(
+ parse_quote!(#fty_static: yoke::Yokeable<'a, Output = #fty_static>),
+ );
}
}
if has_ty || has_lt {
@@ -135,7 +136,7 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
// that the lifetimes are covariant, since this requirement
// must already be true for the type that implements transform_owned().
quote! {
- <#fty as yoke::Yokeable<'a>>::transform_owned(#field)
+ <#fty_static as yoke::Yokeable<'a>>::transform_owned(#field)
}
} else {
// No nested lifetimes, so nothing to be done
@@ -143,6 +144,30 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
}
})
});
+ 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,)*
@@ -150,6 +175,12 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
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
@@ -158,7 +189,7 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
}
#[inline]
fn transform_owned(self) -> Self::Output {
- match self { #body }
+ match self { #owned_body }
}
#[inline]
unsafe fn make(this: Self::Output) -> Self {
@@ -206,6 +237,7 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
// 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(clippy::forget_copy)] // This is a noop if the struct is copy, which Clippy doesn't like
mem::forget(this);
ptr::read(ptr)
}
@@ -216,9 +248,6 @@ fn yokeable_derive_impl(input: &DeriveInput) -> TokenStream2 {
unsafe { f(core::mem::transmute::<&'a mut Self, &'a mut Self::Output>(self)) }
}
}
- // This is safe because it is in the same block as the above impl, which only compiles
- // if 'a is a covariant lifetime.
- unsafe impl<'a, #(#tybounds),*> yoke::IsCovariant<'a> for #name<'a, #(#typarams),*> where #(#static_bounds),* {}
}
}
}