Skip to content

Commit b5f6b33

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dt-ffi-cleanup-old
Conflicts: ffi/capi/bindings/js/index.d.ts ffi/capi/bindings/js/index.mjs ffi/capi/src/lib.rs
2 parents 3111f82 + f037352 commit b5f6b33

File tree

83 files changed

+406
-793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+406
-793
lines changed

components/calendar/src/cal/hijri.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl HijriUmmAlQura {
184184
icu_provider::gen_buffer_data_constructors!(() -> error: DataError,
185185
functions: [
186186
new: skip,
187-
try_new_with_buffer_provider,
187+
try_new_with_buffer_provider,
188188
try_new_unstable,
189189
Self,
190190
]);

components/calendar/src/cal/japanese.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl Japanese {
116116
icu_provider::gen_buffer_data_constructors!(() -> error: DataError,
117117
functions: [
118118
new: skip,
119-
try_new_with_buffer_provider,
119+
try_new_with_buffer_provider,
120120
try_new_unstable,
121121
Self,
122122
]);
@@ -169,7 +169,7 @@ impl JapaneseExtended {
169169
icu_provider::gen_buffer_data_constructors!(() -> error: DataError,
170170
functions: [
171171
new: skip,
172-
try_new_with_buffer_provider,
172+
try_new_with_buffer_provider,
173173
try_new_unstable,
174174
Self,
175175
]);

components/casemap/src/titlecase.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl TitlecaseMapper<CaseMapper> {
215215
icu_provider::gen_buffer_data_constructors!(() -> error: DataError,
216216
functions: [
217217
new: skip,
218-
try_new_with_buffer_provider,
218+
try_new_with_buffer_provider,
219219
try_new_unstable,
220220
Self,
221221
]);

components/collator/src/comparison.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl Collator {
280280
(prefs: CollatorPreferences, options: CollatorOptions) -> error: DataError,
281281
functions: [
282282
try_new: skip,
283-
try_new_with_buffer_provider,
283+
try_new_with_buffer_provider,
284284
try_new_unstable,
285285
Self
286286
]

components/collator/src/options.rs

+5-47
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,6 @@ pub enum CaseLevel {
225225
On = 1,
226226
}
227227

228-
/// Whether second level compares the last accent difference
229-
/// instead of the first accent difference.
230-
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
231-
#[repr(u8)]
232-
#[non_exhaustive]
233-
pub enum BackwardSecondLevel {
234-
/// Leave off the backward second level option. Diacritics in the second level will be ordered by
235-
/// default from beginning to end.
236-
Off = 0,
237-
/// Turn on backward second level ordering so that the second level compares backwards, starting
238-
/// from the last diacritic letter and moving towards the beginning.
239-
On = 1,
240-
}
241-
242228
/// Options settable by the user of the API.
243229
///
244230
/// With the exception of reordering (BCP47 `kr`), options that can by implied by locale are
@@ -283,17 +269,15 @@ pub enum BackwardSecondLevel {
283269
/// See the [spec](https://www.unicode.org/reports/tr35/tr35-collation.html#Case_Parameters).
284270
/// This is the BCP47 key `kc`. The default is [`CaseLevel::Off`].
285271
///
286-
/// ## Backward second level
287-
///
288-
/// Compare the second level in backward order. This is the BCP47 key `kb`. `kb`
289-
/// is prohibited by ECMA-402. The default is [`BackwardSecondLevel::Off`], except
290-
/// for Canadian French.
291-
///
292272
/// # Unsupported BCP47 options
293273
///
294274
/// Reordering (BCP47 `kr`) currently cannot be set via the API and is implied
295275
/// by the locale of the collation. `kr` is prohibited by ECMA-402.
296276
///
277+
/// Backward second level (BCP47 `kb`) cannot be set via the API and is implied
278+
/// by the locale of the collation (in practice only `fr-CA` turns it on and it's
279+
/// off otherwise). `kb` is prohibited by ECMA-402.
280+
///
297281
/// Normalization is always enabled and cannot be turned off. Therefore, there
298282
/// is no option corresponding to BCP47 `kk`. `kk` is prohibited by ECMA-402.
299283
///
@@ -330,8 +314,6 @@ pub struct CollatorOptions {
330314
pub max_variable: Option<MaxVariable>,
331315
/// User-specified case level collation option.
332316
pub case_level: Option<CaseLevel>,
333-
/// User-specified backward second level collation option.
334-
pub backward_second_level: Option<BackwardSecondLevel>,
335317
}
336318

337319
impl CollatorOptions {
@@ -342,7 +324,6 @@ impl CollatorOptions {
342324
alternate_handling: None,
343325
max_variable: None,
344326
case_level: None,
345-
backward_second_level: None,
346327
}
347328
}
348329
}
@@ -359,7 +340,6 @@ impl From<ResolvedCollatorOptions> for CollatorOptions {
359340
alternate_handling: Some(options.alternate_handling),
360341
max_variable: Some(options.max_variable),
361342
case_level: Some(options.case_level),
362-
backward_second_level: Some(options.backward_second_level),
363343
}
364344
}
365345
}
@@ -403,8 +383,6 @@ pub struct ResolvedCollatorOptions {
403383
pub case_level: CaseLevel,
404384
/// Resolved numeric collation option.
405385
pub numeric: CollationNumericOrdering,
406-
/// Resolved backward second level collation option.
407-
pub backward_second_level: BackwardSecondLevel,
408386
}
409387

410388
impl From<CollatorOptionsBitField> for ResolvedCollatorOptions {
@@ -424,11 +402,7 @@ impl From<CollatorOptionsBitField> for ResolvedCollatorOptions {
424402
} else {
425403
CollationNumericOrdering::False
426404
},
427-
backward_second_level: if options.backward_second_level() {
428-
BackwardSecondLevel::On
429-
} else {
430-
BackwardSecondLevel::Off
431-
},
405+
// `options.backward_second_level()` not exposed.
432406
}
433407
}
434408
}
@@ -660,21 +634,6 @@ impl CollatorOptionsBitField {
660634
}
661635
}
662636

663-
pub fn set_backward_second_level_from_enum(
664-
&mut self,
665-
backward_second_level: Option<BackwardSecondLevel>,
666-
) {
667-
match backward_second_level {
668-
Some(BackwardSecondLevel::On) => {
669-
self.set_backward_second_level(Some(true));
670-
}
671-
Some(BackwardSecondLevel::Off) => {
672-
self.set_backward_second_level(Some(false));
673-
}
674-
None => self.set_backward_second_level(None),
675-
}
676-
}
677-
678637
/// Whether sequences of decimal digits are compared according
679638
/// to their numeric value.
680639
pub fn numeric(self) -> bool {
@@ -784,7 +743,6 @@ impl From<CollatorOptions> for CollatorOptionsBitField {
784743
result.set_max_variable(options.max_variable);
785744
result.set_alternate_handling(options.alternate_handling);
786745
result.set_case_level_from_enum(options.case_level);
787-
result.set_backward_second_level_from_enum(options.backward_second_level);
788746
result
789747
}
790748
}

components/collator/tests/tests.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1605,10 +1605,8 @@ fn test_backward_second_level() {
16051605
}
16061606
}
16071607

1608-
options.backward_second_level = Some(BackwardSecondLevel::On);
1609-
16101608
{
1611-
let collator = Collator::try_new(Default::default(), options).unwrap();
1609+
let collator = Collator::try_new(locale!("fr-CA").into(), options).unwrap();
16121610

16131611
{
16141612
let cases = ["cote", "côte", "coté", "côté"];
@@ -1805,7 +1803,6 @@ fn test_default_resolved_options() {
18051803
assert_eq!(resolved.max_variable, MaxVariable::Punctuation);
18061804
assert_eq!(resolved.case_level, CaseLevel::Off);
18071805
assert_eq!(resolved.numeric, CollationNumericOrdering::False);
1808-
assert_eq!(resolved.backward_second_level, BackwardSecondLevel::Off);
18091806

18101807
assert_eq!(collator.compare("𝕒", "A"), core::cmp::Ordering::Less);
18111808
assert_eq!(collator.compare("coté", "côte"), core::cmp::Ordering::Less);
@@ -1822,7 +1819,6 @@ fn test_data_resolved_options_th() {
18221819
assert_eq!(resolved.max_variable, MaxVariable::Punctuation);
18231820
assert_eq!(resolved.case_level, CaseLevel::Off);
18241821
assert_eq!(resolved.numeric, CollationNumericOrdering::False);
1825-
assert_eq!(resolved.backward_second_level, BackwardSecondLevel::Off);
18261822

18271823
// There's a separate more comprehensive test for the shifted behavior
18281824
assert_eq!(collator.compare("𝕒", "A"), core::cmp::Ordering::Less);
@@ -1840,7 +1836,6 @@ fn test_data_resolved_options_da() {
18401836
assert_eq!(resolved.max_variable, MaxVariable::Punctuation);
18411837
assert_eq!(resolved.case_level, CaseLevel::Off);
18421838
assert_eq!(resolved.numeric, CollationNumericOrdering::False);
1843-
assert_eq!(resolved.backward_second_level, BackwardSecondLevel::Off);
18441839

18451840
assert_eq!(collator.compare("𝕒", "A"), core::cmp::Ordering::Greater);
18461841
assert_eq!(collator.compare("coté", "côte"), core::cmp::Ordering::Less);
@@ -1857,7 +1852,7 @@ fn test_data_resolved_options_fr_ca() {
18571852
assert_eq!(resolved.max_variable, MaxVariable::Punctuation);
18581853
assert_eq!(resolved.case_level, CaseLevel::Off);
18591854
assert_eq!(resolved.numeric, CollationNumericOrdering::False);
1860-
assert_eq!(resolved.backward_second_level, BackwardSecondLevel::On);
1855+
// bacward second level is hidden from the API
18611856

18621857
assert_eq!(collator.compare("𝕒", "A"), core::cmp::Ordering::Less);
18631858
assert_eq!(
@@ -1879,7 +1874,7 @@ fn test_manual_and_data_resolved_options_fr_ca() {
18791874
assert_eq!(resolved.max_variable, MaxVariable::Punctuation);
18801875
assert_eq!(resolved.case_level, CaseLevel::Off);
18811876
assert_eq!(resolved.numeric, CollationNumericOrdering::False);
1882-
assert_eq!(resolved.backward_second_level, BackwardSecondLevel::On);
1877+
// backwards second level is hidden from the API
18831878

18841879
assert_eq!(collator.compare("𝕒", "A"), core::cmp::Ordering::Greater);
18851880
assert_eq!(
@@ -1901,7 +1896,6 @@ fn test_manual_resolved_options_da() {
19011896
assert_eq!(resolved.max_variable, MaxVariable::Punctuation);
19021897
assert_eq!(resolved.case_level, CaseLevel::Off);
19031898
assert_eq!(resolved.numeric, CollationNumericOrdering::False);
1904-
assert_eq!(resolved.backward_second_level, BackwardSecondLevel::Off);
19051899

19061900
assert_eq!(collator.compare("𝕒", "A"), core::cmp::Ordering::Less);
19071901
assert_eq!(collator.compare("coté", "côte"), core::cmp::Ordering::Less);

components/datetime/src/neo.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ impl<C: CldrCalendar, FSet: DateTimeMarkers> FixedCalendarDateTimeFormatter<C, F
954954
/// equivalent_builder.date_fields = Some(DateFields::YMD);
955955
/// equivalent_builder.time_precision = Some(TimePrecision::Minute);
956956
/// equivalent_builder.alignment = Some(Alignment::Column);
957+
/// equivalent_builder.year_style = None;
957958
/// assert_eq!(
958959
/// builder,
959960
/// equivalent_builder,
@@ -1127,7 +1128,7 @@ impl<FSet: DateTimeMarkers> DateTimeFormatter<FSet> {
11271128
/// // Create a simple YMDT formatter:
11281129
/// let formatter = DateTimeFormatter::try_new(
11291130
/// locale!("und").into(),
1130-
/// YMDT::long().hm().with_alignment(Alignment::Column)
1131+
/// YMDT::long().with_alignment(Alignment::Column)
11311132
/// )
11321133
/// .unwrap();
11331134
///
@@ -1138,8 +1139,9 @@ impl<FSet: DateTimeMarkers> DateTimeFormatter<FSet> {
11381139
/// let mut equivalent_builder = FieldSetBuilder::default();
11391140
/// equivalent_builder.length = Some(Length::Long);
11401141
/// equivalent_builder.date_fields = Some(DateFields::YMD);
1141-
/// equivalent_builder.time_precision = Some(TimePrecision::Minute);
1142+
/// equivalent_builder.time_precision = Some(TimePrecision::Second); // set automatically
11421143
/// equivalent_builder.alignment = Some(Alignment::Column);
1144+
/// equivalent_builder.year_style = None;
11431145
/// assert_eq!(
11441146
/// builder,
11451147
/// equivalent_builder,

components/datetime/src/raw/neo.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -643,14 +643,19 @@ impl DateTimeZonePatternSelectionData {
643643

644644
/// Converts one of these into a corresponding [`builder::FieldSetBuilder`]
645645
pub(crate) fn to_builder(&self) -> builder::FieldSetBuilder {
646+
let time_precision = if self.time.payload.is_payload() {
647+
Some(self.options.time_precision.unwrap_or_default())
648+
} else {
649+
None
650+
};
646651
let zone_style = self.zone.as_ref().map(|zone| {
647652
let ZonePatternSelectionData::SinglePatternItem(field_set, _) = zone;
648653
field_set.to_zone_style()
649654
});
650655
builder::FieldSetBuilder {
651656
length: self.options.length,
652657
date_fields: self.options.date_fields,
653-
time_precision: self.options.time_precision,
658+
time_precision,
654659
zone_style,
655660
alignment: self.options.alignment,
656661
year_style: self.options.year_style,

components/experimental/src/dimension/currency/compact_formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl CompactCurrencyFormatter {
7171
(prefs: CompactCurrencyFormatterPreferences, options: CompactCurrencyFormatterOptions) -> error: DataError,
7272
functions: [
7373
try_new: skip,
74-
try_new_with_buffer_provider,
74+
try_new_with_buffer_provider,
7575
try_new_unstable,
7676
Self
7777
]

components/experimental/src/dimension/currency/formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl CurrencyFormatter {
6060
(prefs: CurrencyFormatterPreferences, options: super::options::CurrencyFormatterOptions) -> error: DataError,
6161
functions: [
6262
try_new: skip,
63-
try_new_with_buffer_provider,
63+
try_new_with_buffer_provider,
6464
try_new_unstable,
6565
Self
6666
]

components/experimental/src/dimension/currency/long_compact_formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl LongCompactCurrencyFormatter {
6868
) -> error: DataError,
6969
functions: [
7070
try_new: skip,
71-
try_new_with_buffer_provider,
71+
try_new_with_buffer_provider,
7272
try_new_unstable,
7373
Self
7474
]

components/experimental/src/dimension/currency/long_formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl LongCurrencyFormatter {
4545
(prefs: CurrencyFormatterPreferences, currency_code: &CurrencyCode) -> error: DataError,
4646
functions: [
4747
try_new: skip,
48-
try_new_with_buffer_provider,
48+
try_new_with_buffer_provider,
4949
try_new_unstable,
5050
Self
5151
]

components/experimental/src/dimension/percent/formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl PercentFormatter<DecimalFormatter> {
5353
(prefs: PercentFormatterPreferences, options: PercentFormatterOptions) -> error: DataError,
5454
functions: [
5555
try_new: skip,
56-
try_new_with_buffer_provider,
56+
try_new_with_buffer_provider,
5757
try_new_unstable,
5858
Self
5959
]

components/experimental/src/dimension/units/formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl UnitsFormatter {
6464
(prefs: UnitsFormatterPreferences, unit: &str, options: super::options::UnitsFormatterOptions) -> error: DataError,
6565
functions: [
6666
try_new: skip,
67-
try_new_with_buffer_provider,
67+
try_new_with_buffer_provider,
6868
try_new_unstable,
6969
Self
7070
]

components/experimental/src/displaynames/displaynames.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl RegionDisplayNames {
5252
/// Creates a new [`RegionDisplayNames`] from locale data and an options bag using compiled data.
5353
functions: [
5454
try_new,
55-
try_new_with_buffer_provider,
55+
try_new_with_buffer_provider,
5656
try_new_unstable,
5757
Self
5858
]
@@ -119,7 +119,7 @@ impl ScriptDisplayNames {
119119
/// Creates a new [`ScriptDisplayNames`] from locale data and an options bag using compiled data.
120120
functions: [
121121
try_new,
122-
try_new_with_buffer_provider,
122+
try_new_with_buffer_provider,
123123
try_new_unstable,
124124
Self
125125
]
@@ -187,7 +187,7 @@ impl VariantDisplayNames {
187187
/// Creates a new [`VariantDisplayNames`] from locale data and an options bag using compiled data.
188188
functions: [
189189
try_new,
190-
try_new_with_buffer_provider,
190+
try_new_with_buffer_provider,
191191
try_new_unstable,
192192
Self
193193
]
@@ -250,7 +250,7 @@ impl LanguageDisplayNames {
250250
/// Creates a new [`LanguageDisplayNames`] from locale data and an options bag using compiled data.
251251
functions: [
252252
try_new,
253-
try_new_with_buffer_provider,
253+
try_new_with_buffer_provider,
254254
try_new_unstable,
255255
Self
256256
]
@@ -334,7 +334,7 @@ impl LocaleDisplayNamesFormatter {
334334
/// Creates a new [`LocaleDisplayNamesFormatter`] from locale data and an options bag using compiled data.
335335
functions: [
336336
try_new,
337-
try_new_with_buffer_provider,
337+
try_new_with_buffer_provider,
338338
try_new_unstable,
339339
Self
340340
]

components/experimental/src/duration/formatter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl DurationFormatter {
195195
(prefs: DurationFormatterPreferences, options: ValidatedDurationFormatterOptions) -> error: DataError,
196196
functions: [
197197
try_new: skip,
198-
try_new_with_buffer_provider,
198+
try_new_with_buffer_provider,
199199
try_new_unstable,
200200
Self
201201
]

0 commit comments

Comments
 (0)