diff --git a/CHANGELOG.md b/CHANGELOG.md index 57aaa1f7138..d4cad320bb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ - Fix issue in C++ bindings where `diplomat::result::Ok` and `Err` have ambiguous template deduction errors in their constructors, on Clang. (https://github.com/unicode-org/icu4x/pull/4615) - `icu_capi@1.4.1` + - Stricter version dependency on data crates + - `icu_properties@1.4.2`, `icu_normalizer@1.4.3`, `icu_properties_data@1.4.1` + - Enforce C,packed, not just packed, on ULE types, fixing for incoming changes to `repr(Rust)` (https://github.com/unicode-org/icu4x/pull/5049) + - `icu_casemap@1.4.1`, `icu_properties@1.4.3` + - A full fix also needs `zerovec@0.10.3`,`zerovec_derive@0.10.3` + ## icu4x 1.4 (Nov 16, 2023) diff --git a/Cargo.lock b/Cargo.lock index 53e0a8b03a9..d2326004e86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1431,7 +1431,7 @@ dependencies = [ [[package]] name = "icu_casemap" -version = "1.4.0" +version = "1.4.1" dependencies = [ "criterion", "databake", @@ -1853,7 +1853,7 @@ version = "1.4.0" [[package]] name = "icu_properties" -version = "1.4.2" +version = "1.4.3" dependencies = [ "databake", "displaydoc", diff --git a/components/casemap/Cargo.toml b/components/casemap/Cargo.toml index a043cf2a5b1..41beea5daad 100644 --- a/components/casemap/Cargo.toml +++ b/components/casemap/Cargo.toml @@ -14,7 +14,7 @@ homepage.workspace = true include.workspace = true repository.workspace = true rust-version.workspace = true -version.workspace = true +version = "1.4.1" [package.metadata.docs.rs] all-features = true diff --git a/components/casemap/src/provider/exceptions_builder.rs b/components/casemap/src/provider/exceptions_builder.rs index 80c5c8f1e48..133f92b9925 100644 --- a/components/casemap/src/provider/exceptions_builder.rs +++ b/components/casemap/src/provider/exceptions_builder.rs @@ -71,7 +71,7 @@ impl ExceptionHeader { /// In this struct the RESERVED bit is still allowed to be set, and it will produce a different /// exception header, but it will not have any other effects. #[derive(Copy, Clone, PartialEq, Eq, ULE)] -#[repr(packed)] +#[repr(C, packed)] pub struct ExceptionHeaderULE { slot_presence: SlotPresence, bits: ExceptionBitsULE, diff --git a/components/properties/Cargo.toml b/components/properties/Cargo.toml index aee4bc0b2b9..d600f0321f0 100644 --- a/components/properties/Cargo.toml +++ b/components/properties/Cargo.toml @@ -7,7 +7,7 @@ name = "icu_properties" description = "Definitions for Unicode properties" license-file = "LICENSE" -version = "1.4.2" +version = "1.4.3" authors.workspace = true categories.workspace = true edition.workspace = true diff --git a/components/properties/src/provider/bidi_data.rs b/components/properties/src/provider/bidi_data.rs index 465ed4ebb7c..08ba0ce1505 100644 --- a/components/properties/src/provider/bidi_data.rs +++ b/components/properties/src/provider/bidi_data.rs @@ -156,7 +156,7 @@ pub enum CheckedBidiPairedBracketType { #[doc(hidden)] /// needed for datagen but not intended for users #[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)] -#[repr(packed)] +#[repr(C, packed)] pub struct MirroredPairedBracketDataULE([u8; 3]); // Safety (based on the safety checklist on the ULE trait): diff --git a/ffi/capi/dart/package/lib/src/lib.g.dart b/ffi/capi/dart/package/lib/src/lib.g.dart index fcfa0c84c90..513be9b41ce 100644 --- a/ffi/capi/dart/package/lib/src/lib.g.dart +++ b/ffi/capi/dart/package/lib/src/lib.g.dart @@ -9720,10 +9720,12 @@ class ScriptWithExtensionsBorrowed implements ffi.Finalizable { // ignore: non_constant_identifier_names static final _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val = _capi< - ffi.NativeFunction< - ffi.Pointer< - ffi.Opaque> - Function(ffi.Pointer, ffi.Uint32)>>( + ffi + .NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi + .Uint32)>>( 'ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val') .asFunction< ffi.Pointer Function( @@ -9759,10 +9761,12 @@ class ScriptWithExtensionsBorrowed implements ffi.Finalizable { // ignore: non_constant_identifier_names static final _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set = _capi< - ffi.NativeFunction< - ffi.Pointer< - ffi.Opaque> - Function(ffi.Pointer, ffi.Uint16)>>( + ffi + .NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi + .Uint16)>>( 'ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set') .asFunction< ffi.Pointer Function( diff --git a/ffi/capi/tests/missing_apis.txt b/ffi/capi/tests/missing_apis.txt index 33caa29238c..bade3d89407 100644 --- a/ffi/capi/tests/missing_apis.txt +++ b/ffi/capi/tests/missing_apis.txt @@ -14,6 +14,27 @@ # Please check in with @Manishearth, @robertbastian, or @sffc if you have questions +icu::normalizer::uts46::Uts46Mapper#Struct +icu::normalizer::uts46::Uts46Mapper::map_normalize#FnInStruct +icu::normalizer::uts46::Uts46Mapper::new#FnInStruct +icu::normalizer::uts46::Uts46Mapper::normalize_validate#FnInStruct +icu::normalizer::uts46::Uts46Mapper::try_new#FnInStruct +icu::properties::JoiningType#Struct +icu::properties::JoiningType::DualJoining#AssociatedConstantInStruct +icu::properties::JoiningType::JoinCausing#AssociatedConstantInStruct +icu::properties::JoiningType::LeftJoining#AssociatedConstantInStruct +icu::properties::JoiningType::NonJoining#AssociatedConstantInStruct +icu::properties::JoiningType::RightJoining#AssociatedConstantInStruct +icu::properties::JoiningType::Transparent#AssociatedConstantInStruct +icu::properties::JoiningType::TryFromU32Error#AssociatedTypeInStruct +icu::properties::JoiningType::enum_to_long_name_mapper#FnInStruct +icu::properties::JoiningType::enum_to_short_name_mapper#FnInStruct +icu::properties::JoiningType::get_enum_to_long_name_mapper#FnInStruct +icu::properties::JoiningType::get_enum_to_short_name_mapper#FnInStruct +icu::properties::JoiningType::get_name_to_enum_mapper#FnInStruct +icu::properties::JoiningType::name_to_enum_mapper#FnInStruct +icu::properties::JoiningType::to_u32#FnInStruct +icu::properties::JoiningType::try_from_u32#FnInStruct icu::properties::bidi_data::BidiAuxiliaryProperties#Struct icu::properties::bidi_data::BidiAuxiliaryProperties::from_data#FnInStruct icu::properties::bidi_data::BidiAuxiliaryPropertiesBorrowed#Struct @@ -22,6 +43,8 @@ icu::properties::bidi_data::BidiAuxiliaryPropertiesBorrowed::get32_pairing_props icu::properties::bidi_data::BidiMirroringProperties#Struct icu::properties::bidi_data::BidiPairingProperties#Enum icu::properties::bidi_data::bidi_auxiliary_properties#Fn +icu::properties::maps::joining_type#Fn +icu::properties::maps::load_joining_type#Fn icu::properties::names::PropertyEnumToValueNameLinearMapper#Struct icu::properties::names::PropertyEnumToValueNameLinearMapperBorrowed#Struct icu::properties::names::PropertyEnumToValueNameLinearMapperBorrowed::get#FnInStruct diff --git a/ffi/gn/Cargo.lock b/ffi/gn/Cargo.lock index 00623883d9d..3d83905e25e 100644 --- a/ffi/gn/Cargo.lock +++ b/ffi/gn/Cargo.lock @@ -302,7 +302,7 @@ dependencies = [ [[package]] name = "icu_casemap" -version = "1.4.0" +version = "1.4.1" dependencies = [ "displaydoc", "icu_collections", @@ -403,7 +403,7 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "1.4.1" +version = "1.4.3" dependencies = [ "displaydoc", "icu_collections", @@ -429,7 +429,7 @@ dependencies = [ [[package]] name = "icu_properties" -version = "1.4.0" +version = "1.4.3" dependencies = [ "displaydoc", "icu_collections", diff --git a/ffi/gn/icu4x/BUILD.gn b/ffi/gn/icu4x/BUILD.gn index 0b5f531c1fb..dff8d3fcdbd 100644 --- a/ffi/gn/icu4x/BUILD.gn +++ b/ffi/gn/icu4x/BUILD.gn @@ -197,7 +197,7 @@ rust_library("icu-v1_4_0") { deps = [] deps += [ ":icu_calendar-v1_4_0" ] - deps += [ ":icu_casemap-v1_4_0" ] + deps += [ ":icu_casemap-v1_4_1" ] deps += [ ":icu_collator-v1_4_0" ] deps += [ ":icu_collections-v1_4_0" ] deps += [ ":icu_datetime-v1_4_0" ] @@ -205,9 +205,9 @@ rust_library("icu-v1_4_0") { deps += [ ":icu_list-v1_4_0" ] deps += [ ":icu_locid-v1_4_0" ] deps += [ ":icu_locid_transform-v1_4_0" ] - deps += [ ":icu_normalizer-v1_4_1" ] + deps += [ ":icu_normalizer-v1_4_3" ] deps += [ ":icu_plurals-v1_4_0" ] - deps += [ ":icu_properties-v1_4_0" ] + deps += [ ":icu_properties-v1_4_3" ] deps += [ ":icu_provider-v1_4_0" ] deps += [ ":icu_segmenter-v1_4_0" ] deps += [ ":icu_timezone-v1_4_0" ] @@ -260,7 +260,7 @@ rust_library("icu_capi-v1_4_1") { deps += [ ":diplomat-runtime-v0_7_0" ] deps += [ ":fixed_decimal-v0_5_5" ] deps += [ ":icu_calendar-v1_4_0" ] - deps += [ ":icu_casemap-v1_4_0" ] + deps += [ ":icu_casemap-v1_4_1" ] deps += [ ":icu_collator-v1_4_0" ] deps += [ ":icu_collections-v1_4_0" ] deps += [ ":icu_datetime-v1_4_0" ] @@ -268,9 +268,9 @@ rust_library("icu_capi-v1_4_1") { deps += [ ":icu_list-v1_4_0" ] deps += [ ":icu_locid-v1_4_0" ] deps += [ ":icu_locid_transform-v1_4_0" ] - deps += [ ":icu_normalizer-v1_4_1" ] + deps += [ ":icu_normalizer-v1_4_3" ] deps += [ ":icu_plurals-v1_4_0" ] - deps += [ ":icu_properties-v1_4_0" ] + deps += [ ":icu_properties-v1_4_3" ] deps += [ ":icu_provider-v1_4_0" ] deps += [ ":icu_provider_adapters-v1_4_0" ] deps += [ ":icu_segmenter-v1_4_0" ] @@ -304,16 +304,16 @@ rust_library("icu_capi-v1_4_1") { visibility = [ ":*" ] } -rust_library("icu_casemap-v1_4_0") { +rust_library("icu_casemap-v1_4_1") { crate_name = "icu_casemap" crate_root = "//components/casemap/src/lib.rs" - output_name = "icu_casemap-cbaadac30fa1a00b" + output_name = "icu_casemap-dcd3c1c9f13af18b" deps = [] deps += [ ":displaydoc-v0_2_4($host_toolchain)" ] deps += [ ":icu_collections-v1_4_0" ] deps += [ ":icu_locid-v1_4_0" ] - deps += [ ":icu_properties-v1_4_0" ] + deps += [ ":icu_properties-v1_4_3" ] deps += [ ":icu_provider-v1_4_0" ] deps += [ ":writeable-v0_5_4" ] deps += [ ":zerovec-v0_10_1" ] @@ -323,8 +323,8 @@ rust_library("icu_casemap-v1_4_0") { rustflags = [ "--cap-lints=allow", "--edition=2021", - "-Cmetadata=cbaadac30fa1a00b", - "-Cextra-filename=-cbaadac30fa1a00b", + "-Cmetadata=dcd3c1c9f13af18b", + "-Cextra-filename=-dcd3c1c9f13af18b", ] visibility = [ ":*" ] @@ -339,8 +339,8 @@ rust_library("icu_collator-v1_4_0") { deps += [ ":displaydoc-v0_2_4($host_toolchain)" ] deps += [ ":icu_collections-v1_4_0" ] deps += [ ":icu_locid-v1_4_0" ] - deps += [ ":icu_normalizer-v1_4_1" ] - deps += [ ":icu_properties-v1_4_0" ] + deps += [ ":icu_normalizer-v1_4_3" ] + deps += [ ":icu_properties-v1_4_3" ] deps += [ ":icu_provider-v1_4_0" ] deps += [ ":smallvec-v1_10_0" ] deps += [ ":utf16_iter-v1_0_4" ] @@ -510,15 +510,15 @@ rust_library("icu_locid_transform-v1_4_0") { visibility = [ ":*" ] } -rust_library("icu_normalizer-v1_4_1") { +rust_library("icu_normalizer-v1_4_3") { crate_name = "icu_normalizer" crate_root = "//components/normalizer/src/lib.rs" - output_name = "icu_normalizer-95d3055564b72a64" + output_name = "icu_normalizer-93d3ddd5c25aaf29" deps = [] deps += [ ":displaydoc-v0_2_4($host_toolchain)" ] deps += [ ":icu_collections-v1_4_0" ] - deps += [ ":icu_properties-v1_4_0" ] + deps += [ ":icu_properties-v1_4_3" ] deps += [ ":icu_provider-v1_4_0" ] deps += [ ":smallvec-v1_10_0" ] deps += [ ":utf16_iter-v1_0_4" ] @@ -531,8 +531,8 @@ rust_library("icu_normalizer-v1_4_1") { rustflags = [ "--cap-lints=allow", "--edition=2021", - "-Cmetadata=95d3055564b72a64", - "-Cextra-filename=-95d3055564b72a64", + "-Cmetadata=93d3ddd5c25aaf29", + "-Cextra-filename=-93d3ddd5c25aaf29", ] visibility = [ ":*" ] @@ -562,10 +562,10 @@ rust_library("icu_plurals-v1_4_0") { visibility = [ ":*" ] } -rust_library("icu_properties-v1_4_0") { +rust_library("icu_properties-v1_4_3") { crate_name = "icu_properties" crate_root = "//components/properties/src/lib.rs" - output_name = "icu_properties-dacf022aed7923a8" + output_name = "icu_properties-a28d00ec1785b300" deps = [] deps += [ ":displaydoc-v0_2_4($host_toolchain)" ] @@ -580,8 +580,8 @@ rust_library("icu_properties-v1_4_0") { rustflags = [ "--cap-lints=allow", "--edition=2021", - "-Cmetadata=dacf022aed7923a8", - "-Cextra-filename=-dacf022aed7923a8", + "-Cmetadata=a28d00ec1785b300", + "-Cextra-filename=-a28d00ec1785b300", "--cfg=feature=\"bidi\"", ] diff --git a/provider/datagen/tests/data/postcard/fingerprints.csv b/provider/datagen/tests/data/postcard/fingerprints.csv index 3102c00dc6e..7dec484a0f7 100644 --- a/provider/datagen/tests/data/postcard/fingerprints.csv +++ b/provider/datagen/tests/data/postcard/fingerprints.csv @@ -4889,6 +4889,7 @@ propnames/from/ccc@1, und, 783B, 38e394b20d58c1df propnames/from/ea@1, und, 105B, 4bc69f982fa6b2de propnames/from/gc@1, und, 747B, 2f7ece7581036df2 propnames/from/gcm@1, und, 907B, 43b812154d2d3914 +propnames/from/jt@1, und, 131B, b45c742d4b17ceb propnames/from/lb@1, und, 963B, bb6e2daf75e2057f propnames/from/sc@1, und, 3640B, d1ed7fca398b05b8 propnames/to/long/linear/GCB@1, und, 151B, 9feae38a09898348 @@ -4898,6 +4899,7 @@ propnames/to/long/linear/WB@1, und, 245B, 7d725adfd056f4a4 propnames/to/long/linear/bc@1, und, 460B, 98758a587d562ad1 propnames/to/long/linear/ea@1, und, 61B, b4df37d762a5c879 propnames/to/long/linear/gc@1, und, 488B, 4786f3c0d2d639d +propnames/to/long/linear/jt@1, und, 88B, d9b49c75470a1afa propnames/to/long/linear/lb@1, und, 598B, 6ee04a546e351ffb propnames/to/long/linear/sc@1, und, 1964B, 9b97b7f85684632c propnames/to/long/sparse/ccc@1, und, 652B, 440a07537c221a20 @@ -4908,6 +4910,7 @@ propnames/to/short/linear/WB@1, und, 111B, 625b4965d4282611 propnames/to/short/linear/bc@1, und, 103B, 85ea5db229b1eaba propnames/to/short/linear/ea@1, und, 24B, 9dcf5f0ed5697f5b propnames/to/short/linear/gc@1, und, 125B, a6da6a4499b7361b +propnames/to/short/linear/jt@1, und, 23B, 4f7c0d697e2b792f propnames/to/short/linear/lb@1, und, 199B, 808bb5403b659e4 propnames/to/short/linear4/sc@1, und, 806B, d488da3356b27392 propnames/to/short/sparse/ccc@1, und, 478B, aa23b3caa16eae5e @@ -5071,6 +5074,7 @@ props/exemplarchars/punctuation@1, tr, 123B, 2e7906785ab47589 props/exemplarchars/punctuation@1, und, 59B, 42e553f11527bac0 props/gc@1, und, 17012B, 1d6406352436488b props/graph@1, und, 5707B, 2fd03ad84767b721 +props/jt@1, und, 6915B, 877aaf1128f9f651 props/lb@1, und, 14856B, 9add7e1b9033c67d props/nfcinert@1, und, 7211B, f1234f4fe31e6a0d props/nfdinert@1, und, 3267B, 20cfe23fc3115a5d diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5879aff6604..d1ea84dba09 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -4,4 +4,6 @@ [toolchain] # Version updated on 2023-10-06 -channel = "1.73" +# Version set to 1.74 for release/1.4 branch on 2024-06-20 +# so that cargo-rdme continues to install +channel = "1.74" diff --git a/utils/zerovec/derive/examples/derives.rs b/utils/zerovec/derive/examples/derives.rs index 40f821023d9..e53c444aaa2 100644 --- a/utils/zerovec/derive/examples/derives.rs +++ b/utils/zerovec/derive/examples/derives.rs @@ -6,7 +6,7 @@ use zerovec::ule::AsULE; use zerovec::ule::EncodeAsVarULE; use zerovec::*; -#[repr(packed)] +#[repr(C, packed)] #[derive(ule::ULE, Copy, Clone)] pub struct FooULE { a: u8, @@ -40,7 +40,7 @@ impl AsULE for Foo { } } -#[repr(packed)] +#[repr(C, packed)] #[derive(ule::VarULE)] pub struct RelationULE { /// This maps to (AndOr, Polarity, Operand), diff --git a/utils/zerovec/derive/src/make_ule.rs b/utils/zerovec/derive/src/make_ule.rs index b31913f0886..6bd26f489c3 100644 --- a/utils/zerovec/derive/src/make_ule.rs +++ b/utils/zerovec/derive/src/make_ule.rs @@ -83,7 +83,7 @@ fn make_ule_enum_impl( attrs: ZeroVecAttrs, ) -> TokenStream2 { // We could support more int reprs in the future if needed - if !utils::has_valid_repr(&input.attrs, |r| r == "u8") { + if !utils::ReprInfo::compute(&input.attrs).u8 { return Error::new( input.span(), "#[make_ule] can only be applied to #[repr(u8)] enums", diff --git a/utils/zerovec/derive/src/ule.rs b/utils/zerovec/derive/src/ule.rs index 6a03c008f4f..755e66a229b 100644 --- a/utils/zerovec/derive/src/ule.rs +++ b/utils/zerovec/derive/src/ule.rs @@ -10,10 +10,10 @@ use syn::spanned::Spanned; use syn::{Data, DeriveInput, Error}; pub fn derive_impl(input: &DeriveInput) -> TokenStream2 { - if !utils::has_valid_repr(&input.attrs, |r| r == "packed" || r == "transparent") { + if !utils::ReprInfo::compute(&input.attrs).cpacked_or_transparent() { return Error::new( input.span(), - "derive(ULE) must be applied to a #[repr(packed)] or #[repr(transparent)] type", + "derive(ULE) must be applied to a #[repr(C, packed)] or #[repr(transparent)] type", ) .to_compile_error(); } diff --git a/utils/zerovec/derive/src/utils.rs b/utils/zerovec/derive/src/utils.rs index e4155076f72..0b28bf6f717 100644 --- a/utils/zerovec/derive/src/utils.rs +++ b/utils/zerovec/derive/src/utils.rs @@ -11,14 +11,38 @@ use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::{Attribute, Error, Field, Fields, Ident, Index, Result, Token}; -// Check that there are repr attributes satisfying the given predicate -pub fn has_valid_repr(attrs: &[Attribute], predicate: impl Fn(&Ident) -> bool + Copy) -> bool { - attrs.iter().filter(|a| a.path().is_ident("repr")).any(|a| { - a.parse_args::() - .ok() - .and_then(|s| s.idents.iter().find(|s| predicate(s)).map(|_| ())) - .is_some() - }) +#[derive(Default)] +pub struct ReprInfo { + pub c: bool, + pub transparent: bool, + pub u8: bool, + pub packed: bool, +} + +impl ReprInfo { + pub fn compute(attrs: &[Attribute]) -> Self { + let mut info = ReprInfo::default(); + for attr in attrs.iter().filter(|a| a.path().is_ident("repr")) { + if let Ok(pieces) = attr.parse_args::() { + for piece in pieces.idents.iter() { + if piece == "C" || piece == "c" { + info.c = true; + } else if piece == "transparent" { + info.transparent = true; + } else if piece == "packed" { + info.packed = true; + } else if piece == "u8" { + info.u8 = true; + } + } + } + } + info + } + + pub fn cpacked_or_transparent(self) -> bool { + (self.c && self.packed) || self.transparent + } } // An attribute that is a list of idents @@ -60,7 +84,7 @@ pub fn repr_for(f: &Fields) -> TokenStream2 { if f.len() == 1 { quote!(transparent) } else { - quote!(packed) + quote!(C, packed) } } diff --git a/utils/zerovec/derive/src/varule.rs b/utils/zerovec/derive/src/varule.rs index 4a586f9547b..82fd702578e 100644 --- a/utils/zerovec/derive/src/varule.rs +++ b/utils/zerovec/derive/src/varule.rs @@ -15,10 +15,10 @@ pub fn derive_impl( input: &DeriveInput, custom_varule_validator: Option, ) -> TokenStream2 { - if !utils::has_valid_repr(&input.attrs, |r| r == "packed" || r == "transparent") { + if !utils::ReprInfo::compute(&input.attrs).cpacked_or_transparent() { return Error::new( input.span(), - "derive(VarULE) must be applied to a #[repr(packed)] or #[repr(transparent)] type", + "derive(VarULE) must be applied to a #[repr(C, packed)] or #[repr(transparent)] type", ) .to_compile_error(); } diff --git a/utils/zerovec/src/flexzerovec/slice.rs b/utils/zerovec/src/flexzerovec/slice.rs index 41cb7116f90..8e8f7570646 100644 --- a/utils/zerovec/src/flexzerovec/slice.rs +++ b/utils/zerovec/src/flexzerovec/slice.rs @@ -13,7 +13,7 @@ use core::ops::Range; const USIZE_WIDTH: usize = mem::size_of::(); /// A zero-copy "slice" that efficiently represents `[usize]`. -#[repr(packed)] +#[repr(C, packed)] pub struct FlexZeroSlice { // Hard Invariant: 1 <= width <= USIZE_WIDTH (which is target_pointer_width) // Soft Invariant: width == the width of the largest element diff --git a/utils/zerovec/src/hashmap/mod.rs b/utils/zerovec/src/hashmap/mod.rs index e3aed11980e..01ccddd5032 100644 --- a/utils/zerovec/src/hashmap/mod.rs +++ b/utils/zerovec/src/hashmap/mod.rs @@ -192,8 +192,7 @@ where (lower, None) => lower, }; - let mut key_hashes = vec![]; - key_hashes.reserve(size_hint); + let mut key_hashes = alloc::vec::Vec::with_capacity(size_hint); let mut keys = K::Container::zvl_with_capacity(size_hint); let mut values = V::Container::zvl_with_capacity(size_hint); for (k, v) in iter { diff --git a/utils/zerovec/src/ule/mod.rs b/utils/zerovec/src/ule/mod.rs index 5a6d9cd4713..757307ada94 100644 --- a/utils/zerovec/src/ule/mod.rs +++ b/utils/zerovec/src/ule/mod.rs @@ -61,7 +61,7 @@ use core::{mem, slice}; /// 6. Acknowledge the following note about the equality invariant. /// /// If the ULE type is a struct only containing other ULE types (or other types which satisfy invariants 1 and 2, -/// like `[u8; N]`), invariants 1 and 2 can be achieved via `#[repr(packed)]` or `#[repr(transparent)]`. +/// like `[u8; N]`), invariants 1 and 2 can be achieved via `#[repr(C, packed)]` or `#[repr(transparent)]`. /// /// # Equality invariant /// @@ -271,7 +271,7 @@ where /// 7. Acknowledge the following note about the equality invariant. /// /// If the ULE type is a struct only containing other ULE/VarULE types (or other types which satisfy invariants 1 and 2, -/// like `[u8; N]`), invariants 1 and 2 can be achieved via `#[repr(packed)]` or `#[repr(transparent)]`. +/// like `[u8; N]`), invariants 1 and 2 can be achieved via `#[repr(C, packed)]` or `#[repr(transparent)]`. /// /// # Equality invariant /// diff --git a/utils/zerovec/src/ule/option.rs b/utils/zerovec/src/ule/option.rs index 9b0dc5b28a1..e8bd0fae498 100644 --- a/utils/zerovec/src/ule/option.rs +++ b/utils/zerovec/src/ule/option.rs @@ -28,7 +28,7 @@ use core::mem::{self, MaybeUninit}; // Invariants: // The MaybeUninit is zeroed when None (bool = false), // and is valid when Some (bool = true) -#[repr(packed)] +#[repr(C, packed)] pub struct OptionULE(bool, MaybeUninit); impl OptionULE { @@ -62,11 +62,11 @@ impl core::fmt::Debug for OptionULE { // Safety (based on the safety checklist on the ULE trait): // 1. OptionULE does not include any uninitialized or padding bytes. -// (achieved by `#[repr(packed)]` on a struct containing only ULE fields, +// (achieved by `#[repr(C, packed)]` on a struct containing only ULE fields, // in the context of this impl. The MaybeUninit is valid for all byte sequences, and we only generate /// zeroed or valid-T byte sequences to fill it) // 2. OptionULE is aligned to 1 byte. -// (achieved by `#[repr(packed)]` on a struct containing only ULE fields, in the context of this impl) +// (achieved by `#[repr(C, packed)]` on a struct containing only ULE fields, in the context of this impl) // 3. The impl of validate_byte_slice() returns an error if any byte is not valid. // 4. The impl of validate_byte_slice() returns an error if there are extra bytes. // 5. The other ULE methods use the default impl. diff --git a/utils/zerovec/src/ule/tuple.rs b/utils/zerovec/src/ule/tuple.rs index 3e0f291b3fa..457a10f41b0 100644 --- a/utils/zerovec/src/ule/tuple.rs +++ b/utils/zerovec/src/ule/tuple.rs @@ -30,15 +30,15 @@ use core::mem; macro_rules! tuple_ule { ($name:ident, $len:literal, [ $($t:ident $i:tt),+ ]) => { #[doc = concat!("ULE type for tuples with ", $len, " elements.")] - #[repr(packed)] + #[repr(C, packed)] #[allow(clippy::exhaustive_structs)] // stable pub struct $name<$($t),+>($(pub $t),+); // Safety (based on the safety checklist on the ULE trait): // 1. TupleULE does not include any uninitialized or padding bytes. - // (achieved by `#[repr(packed)]` on a struct containing only ULE fields) + // (achieved by `#[repr(C, packed)]` on a struct containing only ULE fields) // 2. TupleULE is aligned to 1 byte. - // (achieved by `#[repr(packed)]` on a struct containing only ULE fields) + // (achieved by `#[repr(C, packed)]` on a struct containing only ULE fields) // 3. The impl of validate_byte_slice() returns an error if any byte is not valid. // 4. The impl of validate_byte_slice() returns an error if there are extra bytes. // 5. The other ULE methods use the default impl.