diff --git a/components/datetime/src/calendar.rs b/components/datetime/src/calendar.rs index 2c640f6441..153ac3170f 100644 --- a/components/datetime/src/calendar.rs +++ b/components/datetime/src/calendar.rs @@ -50,15 +50,7 @@ pub trait CldrCalendar: InternalCldrCalendar { type SkeletaV1Marker: DataMarker>; } -/// A calendar that can never exist. -/// -/// Used as a substitute for calendar parameters when a calendar is not needed, -/// such as in a time formatter. -#[derive(Debug)] -#[allow(clippy::exhaustive_enums)] // empty enum -pub enum NeverCalendar {} - -impl CldrCalendar for NeverCalendar { +impl CldrCalendar for () { type YearNamesV1Marker = NeverMarker>; type MonthNamesV1Marker = NeverMarker>; type SkeletaV1Marker = NeverMarker>; @@ -163,7 +155,7 @@ impl CldrCalendar for Roc { type SkeletaV1Marker = RocDateNeoSkeletonPatternsV1Marker; } -impl InternalCldrCalendar for NeverCalendar {} +impl InternalCldrCalendar for () {} impl InternalCldrCalendar for Buddhist {} impl InternalCldrCalendar for Chinese {} impl InternalCldrCalendar for Coptic {} diff --git a/components/datetime/src/format/neo.rs b/components/datetime/src/format/neo.rs index 557addffa2..6b3414aa3d 100644 --- a/components/datetime/src/format/neo.rs +++ b/components/datetime/src/format/neo.rs @@ -1413,7 +1413,6 @@ impl TypedDateTimeNames { /// ``` /// use icu::calendar::Time; /// use icu::datetime::neo_pattern::DateTimePattern; - /// use icu::datetime::NeverCalendar; /// use icu::datetime::TypedDateTimeNames; /// use icu::datetime::neo_skeleton::NeoTimeSkeleton; /// use icu::locale::locale; @@ -1421,7 +1420,7 @@ impl TypedDateTimeNames { /// /// let locale = &locale!("bn").into(); /// - /// let mut names = TypedDateTimeNames::::try_new(&locale).unwrap(); + /// let mut names = TypedDateTimeNames::<(), NeoTimeSkeleton>::try_new(&locale).unwrap(); /// names.include_fixed_decimal_formatter(); /// /// // Create a pattern for the time, which is all numbers diff --git a/components/datetime/src/lib.rs b/components/datetime/src/lib.rs index 474f878abb..542f664467 100644 --- a/components/datetime/src/lib.rs +++ b/components/datetime/src/lib.rs @@ -116,7 +116,7 @@ mod time_zone; mod tz_registry; pub use calendar::CldrCalendar; -pub use calendar::{InternalCldrCalendar, NeverCalendar}; +pub use calendar::InternalCldrCalendar; pub use error::MismatchedCalendarError; pub use format::datetime::DateTimeWriteError; pub use format::neo::{FormattedDateTimePattern, LoadError, SingleLoadError, TypedDateTimeNames}; diff --git a/components/datetime/src/neo_marker.rs b/components/datetime/src/neo_marker.rs index b3d37dd262..cdf9d0fc76 100644 --- a/components/datetime/src/neo_marker.rs +++ b/components/datetime/src/neo_marker.rs @@ -155,14 +155,13 @@ //! use icu::datetime::neo::TypedNeoFormatter; //! use icu::datetime::neo_marker::NeoHourMinuteMarker; //! use icu::datetime::neo_skeleton::NeoSkeletonLength; -//! use icu::datetime::NeverCalendar; //! use icu::locale::locale; //! use writeable::assert_try_writeable_eq; //! //! // By default, en-US uses 12-hour time and fr-FR uses 24-hour time, //! // but we can set overrides. //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("en-US-u-hc-h12").into(), //! NeoHourMinuteMarker::with_length(NeoSkeletonLength::Short), //! ) @@ -172,7 +171,7 @@ //! "4:12 PM" //! ); //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("en-US-u-hc-h23").into(), //! NeoHourMinuteMarker::with_length(NeoSkeletonLength::Short), //! ) @@ -182,7 +181,7 @@ //! "16:12" //! ); //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("fr-FR-u-hc-h12").into(), //! NeoHourMinuteMarker::with_length(NeoSkeletonLength::Short), //! ) @@ -192,7 +191,7 @@ //! "4:12 PM" //! ); //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("fr-FR-u-hc-h23").into(), //! NeoHourMinuteMarker::with_length(NeoSkeletonLength::Short), //! ) @@ -210,11 +209,10 @@ //! use icu::datetime::neo::TypedNeoFormatter; //! use icu::datetime::neo_marker::NeoHourMinuteMarker; //! use icu::datetime::neo_skeleton::NeoSkeletonLength; -//! use icu::datetime::NeverCalendar; //! use icu::locale::locale; //! use writeable::assert_try_writeable_eq; //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("und-u-hc-h11").into(), //! NeoHourMinuteMarker::with_length(NeoSkeletonLength::Short), //! ) @@ -224,7 +222,7 @@ //! "0:00 AM" //! ); //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("und-u-hc-h24").into(), //! NeoHourMinuteMarker::with_length(NeoSkeletonLength::Short), //! ) @@ -246,11 +244,10 @@ //! use icu::datetime::neo_marker::NeoHourMinuteSecondMarker; //! use icu::datetime::neo_skeleton::FractionalSecondDigits; //! use icu::datetime::neo_skeleton::NeoSkeletonLength; -//! use icu::datetime::NeverCalendar; //! use icu::locale::locale; //! use writeable::assert_try_writeable_eq; //! -//! let formatter = TypedNeoFormatter::::try_new( +//! let formatter = TypedNeoFormatter::<(), _>::try_new( //! &locale!("en-US").into(), //! NeoHourMinuteSecondMarker::with_length(NeoSkeletonLength::Short) //! .with_fractional_second_digits(FractionalSecondDigits::F2), @@ -274,7 +271,6 @@ //! use icu::datetime::neo::TypedNeoFormatter; //! use icu::datetime::neo_marker::NeoTimeZoneGenericMarker; //! use icu::datetime::neo_skeleton::NeoSkeletonLength; -//! use icu::datetime::NeverCalendar; //! use icu::datetime::DateTimeWriteError; //! use icu::locale::locale; //! use tinystr::tinystr; @@ -294,7 +290,7 @@ //! .unwrap(); //! //! // Set up the formatter -//! let mut tzf = TypedNeoFormatter::::try_new( +//! let mut tzf = TypedNeoFormatter::<(), _>::try_new( //! &locale!("en").into(), //! NeoTimeZoneGenericMarker::with_length(NeoSkeletonLength::Short), //! ) diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index 11f9922ea1..a3a773079a 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -475,12 +475,10 @@ fn test_time_zone_format_configs() { #[test] fn test_time_zone_format_offset_seconds() { - use icu_datetime::{ - neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength, NeverCalendar, - }; + use icu_datetime::{neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength}; let time_zone = CustomTimeZone::new_with_offset(UtcOffset::try_from_seconds(12).unwrap()); - let tzf = TypedNeoFormatter::::try_new( + let tzf = TypedNeoFormatter::<(), _>::try_new( &locale!("en").into(), NeoTimeZoneOffsetMarker::with_length(NeoSkeletonLength::Medium), ) @@ -492,11 +490,10 @@ fn test_time_zone_format_offset_seconds() { fn test_time_zone_format_offset_not_set_debug_assert_panic() { use icu_datetime::{ neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength, DateTimeWriteError, - NeverCalendar, }; let time_zone = CustomTimeZone::try_from_str("America/Los_Angeles").unwrap(); - let tzf = TypedNeoFormatter::::try_new( + let tzf = TypedNeoFormatter::<(), _>::try_new( &locale!("en").into(), NeoTimeZoneOffsetMarker::with_length(NeoSkeletonLength::Medium), ) diff --git a/ffi/capi/src/datetime_formatter.rs b/ffi/capi/src/datetime_formatter.rs index 8c22bc5dee..5a0af9e149 100644 --- a/ffi/capi/src/datetime_formatter.rs +++ b/ffi/capi/src/datetime_formatter.rs @@ -10,7 +10,6 @@ pub mod ffi { use icu_datetime::{ neo_marker::{NeoHourMinuteMarker, NeoYearMonthDayHourMinuteMarker, NeoYearMonthDayMarker}, neo_skeleton::NeoSkeletonLength, - NeverCalendar, }; use crate::{ @@ -27,9 +26,7 @@ pub mod ffi { #[diplomat::opaque] /// An ICU4X TimeFormatter object capable of formatting an [`Time`] type (and others) as a string #[diplomat::rust_link(icu::datetime, Mod)] - pub struct TimeFormatter( - pub icu_datetime::neo::TypedNeoFormatter, - ); + pub struct TimeFormatter(pub icu_datetime::neo::TypedNeoFormatter<(), NeoHourMinuteMarker>); #[diplomat::enum_convert(icu_datetime::neo_skeleton::NeoSkeletonLength, needs_wildcard)] #[diplomat::rust_link(icu::datetime::neo_skeleton::NeoSkeletonLength, Enum)] diff --git a/tools/make/diplomat-coverage/src/allowlist.rs b/tools/make/diplomat-coverage/src/allowlist.rs index 5514d0b1e4..ef3ecbcfdd 100644 --- a/tools/make/diplomat-coverage/src/allowlist.rs +++ b/tools/make/diplomat-coverage/src/allowlist.rs @@ -420,7 +420,6 @@ lazy_static::lazy_static! { "icu::calendar::gregorian::Gregorian", "icu::calendar::gregorian::GregorianDateInner", "icu::calendar::any_calendar::AnyDateInner", - "icu::datetime::NeverCalendar", // Options bags which are expanded in FFI to regular functions // TODO-2.0: investigate flattening on the rust side too