Skip to content

Avoid using derive on autogenerated packed types, bump zerovec-derive to 0.9.3 #3069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ffi/gn/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions ffi/gn/icu4x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ rust_library("zerovec-v0_9_2") {
deps = []
deps += [ ":yoke-v0_7_0" ]
deps += [ ":zerofrom-v0_1_1" ]
deps += [ ":zerovec-derive-v0_9_2($host_toolchain)" ]
deps += [ ":zerovec-derive-v0_9_3($host_toolchain)" ]

rustenv = []

Expand All @@ -1463,10 +1463,10 @@ rust_library("zerovec-v0_9_2") {
visibility = [ ":*" ]
}

rust_proc_macro("zerovec-derive-v0_9_2") {
rust_proc_macro("zerovec-derive-v0_9_3") {
crate_name = "zerovec_derive"
crate_root = "//utils/zerovec/derive/src/lib.rs"
output_name = "zerovec_derive-7ef1f6966b3a74c7"
output_name = "zerovec_derive-4d58846cb210946f"

deps = []
deps += [ ":proc-macro2-v1_0_32" ]
Expand All @@ -1479,8 +1479,8 @@ rust_proc_macro("zerovec-derive-v0_9_2") {
rustflags = [
"--cap-lints=allow",
"--edition=2018",
"-Cmetadata=7ef1f6966b3a74c7",
"-Cextra-filename=-7ef1f6966b3a74c7",
"-Cmetadata=4d58846cb210946f",
"-Cextra-filename=-4d58846cb210946f",
]

visibility = [ ":*" ]
Expand Down
2 changes: 1 addition & 1 deletion utils/zerovec/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[package]
name = "zerovec-derive"
version = "0.9.2"
version = "0.9.3"
description = "Custom derive for the zerovec crate"
repository = "https://github.com/unicode-org/icu4x"
license = "Unicode-DFS-2016"
Expand Down
16 changes: 15 additions & 1 deletion utils/zerovec/derive/src/make_varule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ pub fn make_varule_impl(attr: AttributeArgs, mut input: DeriveInput) -> TokenStr
let doc = format!("[`VarULE`](zerovec::ule::VarULE) type for {name}");
let varule_struct: DeriveInput = parse_quote!(
#[repr(#repr_attr)]
#[derive(PartialEq, Eq)]
#[doc = #doc]
#vis struct #ule_name #field_inits #semi
);
Expand All @@ -142,6 +141,19 @@ pub fn make_varule_impl(attr: AttributeArgs, mut input: DeriveInput) -> TokenStr
input.span(),
);

let eq_impl = quote!(
impl core::cmp::PartialEq for #ule_name {
fn eq(&self, other: &Self) -> bool {
// The VarULE invariants allow us to assume that equality is byte equality
// in non-safety-critical contexts
<Self as zerovec::ule::VarULE>::as_byte_slice(&self)
== <Self as zerovec::ule::VarULE>::as_byte_slice(&other)
}
}

impl core::cmp::Eq for #ule_name {}
);

let zerofrom_fq_path =
quote!(<#name as zerovec::__zerovec_internal_reexport::ZeroFrom<#ule_name>>);

Expand Down Expand Up @@ -234,6 +246,8 @@ pub fn make_varule_impl(attr: AttributeArgs, mut input: DeriveInput) -> TokenStr

#maybe_ord_impls

#eq_impl

#zmkv

#maybe_ser
Expand Down