Skip to content

Commit 5fdab29

Browse files
committed
Global search-and-replace
1 parent 2c0b3ef commit 5fdab29

File tree

451 files changed

+1112
-1120
lines changed

Some content is hidden

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

451 files changed

+1112
-1120
lines changed

components/locale/src/canonicalizer.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn uts35_rule_matches<'a, I>(
5454
where
5555
I: Iterator<Item = &'a str>,
5656
{
57-
(language.is_unknown() || language == source.language)
57+
(language.is_und() || language == source.language)
5858
&& (script.is_none() || script == source.script)
5959
&& (region.is_none() || region == source.region)
6060
&& {
@@ -95,8 +95,7 @@ fn uts35_replacement<'a, I>(
9595
) where
9696
I: Iterator<Item = &'a str>,
9797
{
98-
if ruletype_has_language || (source.language.is_unknown() && !replacement.language.is_unknown())
99-
{
98+
if ruletype_has_language || (source.language.is_und() && !replacement.language.is_und()) {
10099
source.language = replacement.language;
101100
}
102101
if ruletype_has_script || (source.script.is_none() && replacement.script.is_some()) {
@@ -165,7 +164,7 @@ fn uts35_check_language_rules(
165164
langid: &mut LanguageIdentifier,
166165
alias_data: &DataPayload<LocaleAliasesV1>,
167166
) -> TransformResult {
168-
if !langid.language.is_unknown() {
167+
if !langid.language.is_und() {
169168
let lang: TinyAsciiStr<3> = langid.language.into();
170169
let replacement = if lang.len() == 2 {
171170
alias_data
@@ -341,7 +340,7 @@ impl<Expander: AsRef<LocaleExpander>> LocaleCanonicalizer<Expander> {
341340
continue;
342341
}
343342

344-
if !locale.id.language.is_unknown() {
343+
if !locale.id.language.is_und() {
345344
// If the region is specified, check sgn-region rules first
346345
if let Some(region) = locale.id.region {
347346
if locale.id.language == language!("sgn") {
@@ -517,14 +516,7 @@ impl<Expander: AsRef<LocaleExpander>> LocaleCanonicalizer<Expander> {
517516
// if is_iter_sorted(raw_variants.clone()) { // can we sort at construction?
518517
if uts35_rule_matches(lid, lang, None, None, raw_variants.clone()) {
519518
if let Ok(to) = raw_to.parse() {
520-
uts35_replacement(
521-
lid,
522-
!lang.is_unknown(),
523-
false,
524-
false,
525-
Some(raw_variants),
526-
&to,
527-
);
519+
uts35_replacement(lid, !lang.is_und(), false, false, Some(raw_variants), &to);
528520
return true;
529521
}
530522
}
@@ -551,7 +543,7 @@ impl<Expander: AsRef<LocaleExpander>> LocaleCanonicalizer<Expander> {
551543
if let Ok(to) = raw_to.parse() {
552544
uts35_replacement(
553545
lid,
554-
!from.language.is_unknown(),
546+
!from.language.is_und(),
555547
from.script.is_some(),
556548
from.region.is_some(),
557549
Some(from.variants.iter().map(Variant::as_str)),
@@ -613,7 +605,7 @@ mod test {
613605
let result = result.parse::<Locale>().unwrap();
614606
uts35_replacement(
615607
&mut locale.id,
616-
!rule_0.language.is_unknown(),
608+
!rule_0.language.is_und(),
617609
rule_0.script.is_some(),
618610
rule_0.region.is_some(),
619611
Some(rule_0.variants.iter().map(Variant::as_str)),

components/locale/src/expander.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn update_langid(
156156
) -> TransformResult {
157157
let mut modified = false;
158158

159-
if langid.language.is_unknown() && !language.is_unknown() {
159+
if langid.language.is_und() && !language.is_und() {
160160
langid.language = language;
161161
modified = true;
162162
}
@@ -375,11 +375,11 @@ impl LocaleExpander {
375375
pub fn maximize(&self, langid: &mut LanguageIdentifier) -> TransformResult {
376376
let data = self.as_borrowed();
377377

378-
if !langid.language.is_unknown() && langid.script.is_some() && langid.region.is_some() {
378+
if !langid.language.is_und() && langid.script.is_some() && langid.region.is_some() {
379379
return TransformResult::Unmodified;
380380
}
381381

382-
if !langid.language.is_unknown() {
382+
if !langid.language.is_und() {
383383
if let Some(region) = langid.region {
384384
if let Some(script) = data.get_lr(langid.language, region) {
385385
return update_langid(Language::UND, Some(script), None, langid);
@@ -414,7 +414,7 @@ impl LocaleExpander {
414414

415415
// We failed to find anything in the und-SR, und-S, or und-R tables,
416416
// to fall back to bare "und"
417-
debug_assert!(langid.language.is_unknown());
417+
debug_assert!(langid.language.is_und());
418418
update_langid(
419419
data.get_und().0,
420420
Some(data.get_und().1),
@@ -550,7 +550,7 @@ impl LocaleExpander {
550550
// 3. region
551551
// we need to check all cases, because e.g. for "en-US" the default script is associated
552552
// with "en" but not "en-US"
553-
if !language.is_unknown() {
553+
if !language.is_und() {
554554
if let Some(region) = region {
555555
// 1. we know both language and region
556556
if let Some(script) = data.get_lr(language, region) {

components/locale/src/fallback/algorithms.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl LocaleFallbackIteratorInner<'_> {
121121
return;
122122
}
123123
// 8. Remove language+script
124-
debug_assert!(!locale.language.is_unknown() || locale.script.is_some()); // don't call .step() on und
124+
debug_assert!(!locale.language.is_und() || locale.script.is_some()); // don't call .step() on und
125125
locale.script = None;
126126
locale.language = Language::UND;
127127
}
@@ -139,7 +139,7 @@ impl LocaleFallbackIteratorInner<'_> {
139139
return;
140140
}
141141
// 5. Remove language+script
142-
if !locale.language.is_unknown() || locale.script.is_some() {
142+
if !locale.language.is_und() || locale.script.is_some() {
143143
locale.script = None;
144144
locale.language = Language::UND;
145145
// Don't produce und-variant
@@ -190,7 +190,7 @@ impl LocaleFallbackIteratorInner<'_> {
190190
}
191191

192192
// Remove the script if we have a language
193-
if !locale.language.is_unknown() {
193+
if !locale.language.is_und() {
194194
let language_implied_script = self
195195
.likely_subtags
196196
.language
@@ -498,7 +498,7 @@ mod tests {
498498
if i == 19 {
499499
eprintln!("20 iterations reached!");
500500
}
501-
if it.get().is_unknown() {
501+
if it.get().is_und() {
502502
break;
503503
}
504504
actual_chain.push(it.get().write_to_string().into_owned());

components/locale/src/fallback/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod algorithms;
2020
/// algorithm. See *[the design doc]* for a detailed description and [#2243](
2121
/// https://github.com/unicode-org/icu4x/issues/2243) to track alignment with *UTS #35*.
2222
///
23-
/// If running fallback in a loop, use [`DataLocale::is_unknown()`] to break from the loop.
23+
/// If running fallback in a loop, use [`DataLocale::is_und()`] to break from the loop.
2424
///
2525
/// # Examples
2626
///

components/locale_core/src/data.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,12 @@ impl DataLocale {
318318
/// ```
319319
/// use icu_provider::DataLocale;
320320
///
321-
/// assert!("und".parse::<DataLocale>().unwrap().is_unknown());
322-
/// assert!(!"de-u-sd-denw".parse::<DataLocale>().unwrap().is_unknown());
323-
/// assert!(!"und-ES".parse::<DataLocale>().unwrap().is_unknown());
321+
/// assert!("und".parse::<DataLocale>().unwrap().is_und());
322+
/// assert!(!"de-u-sd-denw".parse::<DataLocale>().unwrap().is_und());
323+
/// assert!(!"und-ES".parse::<DataLocale>().unwrap().is_und());
324324
/// ```
325-
pub fn is_unknown(&self) -> bool {
326-
self.language.is_unknown()
325+
pub fn is_und(&self) -> bool {
326+
self.language.is_und()
327327
&& self.script.is_none()
328328
&& self.region.is_none()
329329
&& self.variant.is_none()

components/locale_core/src/langid.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ impl LanguageIdentifier {
164164
}
165165

166166
/// Whether this language identifier equals [`Self::default`].
167-
pub const fn is_unknown(&self) -> bool {
168-
self.language.is_unknown()
167+
pub const fn is_und(&self) -> bool {
168+
self.language.is_und()
169169
&& self.script.is_none()
170170
&& self.region.is_none()
171171
&& self.variants.is_empty()

components/locale_core/src/preferences/locale.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl LocalePreferences {
158158

159159
/// Extends the preferences with the values from another set of preferences.
160160
pub fn extend(&mut self, other: LocalePreferences) {
161-
if !other.language.is_unknown() {
161+
if !other.language.is_und() {
162162
self.language = other.language;
163163
}
164164
if let Some(script) = other.script {

components/locale_core/src/subtags/language.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Language {
7070

7171
/// Tests if the [`Language`] subtag is the default one (`"und"`).
7272
#[inline]
73-
pub const fn is_unknown(self) -> bool {
73+
pub const fn is_und(self) -> bool {
7474
matches!(self, Self::UND)
7575
}
7676
}

components/locale_core/tests/langid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn test_langid_subtag_language() {
8181

8282
lang = Default::default();
8383
assert_eq!(lang, subtags::Language::UND);
84-
assert!(lang.is_unknown());
84+
assert!(lang.is_und());
8585

8686
assert_writeable_eq!(lang, "und");
8787
}

ffi/capi/src/fallbacker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub mod ffi {
162162
)]
163163
pub fn next(&mut self) -> Option<Box<Locale>> {
164164
let current = self.0.get();
165-
if current.is_unknown() {
165+
if current.is_und() {
166166
None
167167
} else {
168168
let current = *current;

ffi/capi/src/locale_core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub mod ffi {
4242
/// Construct a default undefined [`Locale`] "und".
4343
#[diplomat::rust_link(icu::locale::Locale::default, FnInStruct)]
4444
#[diplomat::rust_link(icu::locale::DataLocale::default, FnInStruct, hidden)]
45-
#[diplomat::rust_link(icu::locale::DataLocale::is_unknown, FnInStruct, hidden)]
45+
#[diplomat::rust_link(icu::locale::DataLocale::is_und, FnInStruct, hidden)]
4646
#[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor)]
4747
pub fn und() -> Box<Locale> {
4848
Box::new(Locale(icu_locale_core::Locale::default()))

provider/adapters/src/fallback/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<P> LocaleFallbackProvider<P> {
171171
}
172172
Ok(None) => {
173173
// If we just checked und, break out of the loop.
174-
if fallback_iterator.get().is_unknown() {
174+
if fallback_iterator.get().is_und() {
175175
break;
176176
}
177177
fallback_iterator.step();

provider/baked/src/export.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl DataExporter for BakedExporter {
479479
&self,
480480
req: icu_provider::DataRequest,
481481
) -> Result<icu_provider::DataResponse<#marker_bake>, icu_provider::DataError> {
482-
if req.id.locale.is_unknown() {
482+
if req.id.locale.is_und() {
483483
Ok(icu_provider::DataResponse {
484484
payload: icu_provider::DataPayload::from_static_ref(Self::#singleton_ident),
485485
metadata: #metadata_bake,
@@ -494,7 +494,7 @@ impl DataExporter for BakedExporter {
494494
#maybe_msrv
495495
impl icu_provider::DryDataProvider<#marker_bake> for $provider {
496496
fn dry_load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponseMetadata, icu_provider::DataError> {
497-
if req.id.locale.is_unknown() {
497+
if req.id.locale.is_und() {
498498
Ok(#metadata_bake)
499499
} else {
500500
Err(icu_provider::DataErrorKind::InvalidRequest.with_req(<#marker_bake as icu_provider::DataMarker>::INFO, req))
@@ -562,7 +562,7 @@ impl DataExporter for BakedExporter {
562562
let needs_fallback = self.use_internal_fallback
563563
&& deduplicated_values
564564
.iter()
565-
.any(|(_, ids)| ids.iter().any(|id| !id.locale.is_unknown()));
565+
.any(|(_, ids)| ids.iter().any(|id| !id.locale.is_und()));
566566

567567
let mut baked_values = deduplicated_values
568568
.iter()
@@ -632,7 +632,7 @@ impl DataExporter for BakedExporter {
632632
metadata.locale = Some(fallback_iterator.take());
633633
break payload;
634634
}
635-
if fallback_iterator.get().is_unknown() {
635+
if fallback_iterator.get().is_und() {
636636
return Err(icu_provider::DataErrorKind::IdentifierNotFound.with_req(<#marker_bake as icu_provider::DataMarker>::INFO, req));
637637
}
638638
fallback_iterator.step();

provider/blob/src/blob_schema.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<'data, LocaleVecFormat: VarZeroVecFormat> BlobSchemaV1<'data, LocaleVecForm
131131
marker: DataMarkerInfo,
132132
req: DataRequest,
133133
) -> Result<(&'data [u8], Option<u64>), DataError> {
134-
if marker.is_singleton && !req.id.locale.is_unknown() {
134+
if marker.is_singleton && !req.id.locale.is_und() {
135135
return Err(DataErrorKind::InvalidRequest.with_req(marker, req));
136136
}
137137
let marker_index = self

provider/core/src/request.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ impl<'a> DataIdentifierCow<'a> {
208208
}
209209

210210
/// Returns whether this id is equal to the default.
211-
pub fn is_unknown(&self) -> bool {
212-
self.marker_attributes.is_empty() && self.locale.is_unknown()
211+
pub fn is_und(&self) -> bool {
212+
self.marker_attributes.is_empty() && self.locale.is_und()
213213
}
214214
}
215215

provider/data/calendar/data/calendar_chinese_v1.rs.data

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/data/calendar/data/calendar_dangi_v1.rs.data

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provider/data/calendar/data/calendar_hijri_simulated_mecca_v1.rs.data

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)