Skip to content

Commit

Permalink
Assorted Rust hygiene fixes (#4911)
Browse files Browse the repository at this point in the history
Fixes #4910
  • Loading branch information
sffc committed May 16, 2024
1 parent c76757e commit 5b15744
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 8 additions & 0 deletions components/datetime/src/fields/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

#[cfg(any(feature = "datagen", feature = "experimental"))]
use crate::fields::FieldLength;
use core::{cmp::Ordering, convert::TryFrom};
use displaydoc::Display;
Expand Down Expand Up @@ -224,13 +225,15 @@ unsafe impl ULE for FieldSymbolULE {

#[derive(Debug, Eq, PartialEq, Clone, Copy)]
#[allow(clippy::exhaustive_enums)] // used in data struct
#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
pub(crate) enum TextOrNumeric {
Text,
Numeric,
}

/// [`FieldSymbols`](FieldSymbol) can be either text or numeric. This categorization is important
/// when matching skeletons with a components [`Bag`](crate::options::components::Bag).
#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
pub(crate) trait LengthType {
fn get_length_type(&self, length: FieldLength) -> TextOrNumeric;
}
Expand Down Expand Up @@ -348,6 +351,7 @@ macro_rules! field_type {
($(#[$enum_attr:meta])* $i:ident; { $( $(#[$variant_attr:meta])* $key:literal => $val:ident = $idx:expr,)* }; $length_type:ident; $ule_name:ident) => (
field_type!($(#[$enum_attr])* $i; {$( $(#[$variant_attr])* $key => $val = $idx,)*}; $ule_name);

#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
impl LengthType for $i {
fn get_length_type(&self, _length: FieldLength) -> TextOrNumeric {
TextOrNumeric::$length_type
Expand Down Expand Up @@ -472,6 +476,7 @@ field_type! (
YearULE
);

#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
impl LengthType for Year {
fn get_length_type(&self, _length: FieldLength) -> TextOrNumeric {
// https://unicode.org/reports/tr35/tr35-dates.html#dfst-year
Expand All @@ -493,6 +498,7 @@ field_type!(
'L' => StandAlone = 1,
}; MonthULE);

#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
impl LengthType for Month {
fn get_length_type(&self, length: FieldLength) -> TextOrNumeric {
match length {
Expand Down Expand Up @@ -596,6 +602,7 @@ field_type!(
WeekdayULE
);

#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
impl LengthType for Weekday {
fn get_length_type(&self, length: FieldLength) -> TextOrNumeric {
match self {
Expand Down Expand Up @@ -662,6 +669,7 @@ field_type!(
TimeZoneULE
);

#[cfg(any(feature = "datagen", feature = "experimental"))] // only referenced in experimental code
impl LengthType for TimeZone {
fn get_length_type(&self, length: FieldLength) -> TextOrNumeric {
use TextOrNumeric::*;
Expand Down
8 changes: 3 additions & 5 deletions provider/blob/benches/auxkey_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

// TODO(review): write macro in a way that doesn't raise this warning
#![allow(semicolon_in_expressions_from_macros)]

extern crate alloc;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand All @@ -21,6 +18,7 @@ struct Baked;
const _: () = {
pub mod icu {
pub use icu_datetime as datetime;
#[allow(unused_imports)] // baked data may or may not need this
pub use icu_locid_transform as locid_transform;
}
icu_datetime_data::make_provider!(Baked);
Expand Down Expand Up @@ -56,7 +54,7 @@ const _: () = {

macro_rules! skeleton_markers {
($cb:ident) => {
$cb!([
$cb! {[
BuddhistDateNeoSkeletonPatternsV1Marker,
ChineseDateNeoSkeletonPatternsV1Marker,
CopticDateNeoSkeletonPatternsV1Marker,
Expand All @@ -70,7 +68,7 @@ macro_rules! skeleton_markers {
JapaneseExtendedDateNeoSkeletonPatternsV1Marker,
PersianDateNeoSkeletonPatternsV1Marker,
RocDateNeoSkeletonPatternsV1Marker,
]);
]}
};
}

Expand Down

0 comments on commit 5b15744

Please sign in to comment.