Skip to content

Commit 359cbd2

Browse files
committed
Use default locale fallback data
1 parent d82a20e commit 359cbd2

File tree

10 files changed

+30
-216
lines changed

10 files changed

+30
-216
lines changed

Cargo.lock

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,7 @@ dependencies = [
17021702
"displaydoc",
17031703
"icu_collections",
17041704
"icu_locale_core",
1705+
"icu_locale_data",
17051706
"icu_provider",
17061707
"potential_utf",
17071708
"tinystr",
@@ -1721,6 +1722,12 @@ dependencies = [
17211722
"zerovec",
17221723
]
17231724

1725+
[[package]]
1726+
name = "icu_locale_data"
1727+
version = "2.0.0"
1728+
source = "registry+https://github.com/rust-lang/crates.io-index"
1729+
checksum = "4fdef0c124749d06a743c69e938350816554eb63ac979166590e2b4ee4252765"
1730+
17241731
[[package]]
17251732
name = "icu_normalizer"
17261733
version = "2.0.0"
@@ -1781,18 +1788,6 @@ dependencies = [
17811788
"zerovec",
17821789
]
17831790

1784-
[[package]]
1785-
name = "icu_provider_adapters"
1786-
version = "2.0.0"
1787-
source = "registry+https://github.com/rust-lang/crates.io-index"
1788-
checksum = "85c260e90e962088d46a1605687f78d3293cc3a34ba66b08ff7361084bc7895e"
1789-
dependencies = [
1790-
"icu_locale",
1791-
"icu_provider",
1792-
"tinystr",
1793-
"zerovec",
1794-
]
1795-
17961791
[[package]]
17971792
name = "id-arena"
17981793
version = "2.2.1"
@@ -3697,7 +3692,6 @@ dependencies = [
36973692
"fluent-syntax",
36983693
"icu_list",
36993694
"icu_locale",
3700-
"icu_provider_adapters",
37013695
"intl-memoizer",
37023696
"rustc_ast",
37033697
"rustc_ast_pretty",

compiler/rustc_baked_icu_data/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
icu_list = { version = "2.0", default-features = false }
9-
icu_locale = { version = "2.0", default-features = false }
9+
icu_locale = { version = "2.0", default-features = false, features = ["compiled_data"] }
1010
icu_provider = { version = "2.0", features = ["baked", "sync"] }
1111
zerovec = "0.11.0"
1212
# tidy-alphabetical-end

compiler/rustc_baked_icu_data/src/data/list_and_v1.rs.data

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
///
1212
/// This macro requires the following crates:
1313
/// * `icu_list`
14+
/// * `icu_locale/compiled_data`
1415
/// * `icu_provider`
1516
/// * `icu_provider/baked`
1617
/// * `zerovec`
@@ -31,8 +32,23 @@ macro_rules! __impl_list_and_v1 {
3132
#[clippy::msrv = "1.82"]
3233
impl icu_provider::DataProvider<icu_list::provider::ListAndV1> for $provider {
3334
fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu_list::provider::ListAndV1>, icu_provider::DataError> {
34-
let metadata = icu_provider::DataResponseMetadata::default();
35-
let Some(payload) = icu_provider::baked::DataStore::get(&Self::DATA_LIST_AND_V1, req.id, req.metadata.attributes_prefix_match) else { return Err(icu_provider::DataErrorKind::IdentifierNotFound.with_req(<icu_list::provider::ListAndV1 as icu_provider::DataMarker>::INFO, req)) };
35+
let mut metadata = icu_provider::DataResponseMetadata::default();
36+
let payload = if let Some(payload) = icu_provider::baked::DataStore::get(&Self::DATA_LIST_AND_V1, req.id, req.metadata.attributes_prefix_match) {
37+
payload
38+
} else {
39+
const FALLBACKER: icu_locale::fallback::LocaleFallbackerWithConfig<'static> = icu_locale::fallback::LocaleFallbacker::new().for_config(<icu_list::provider::ListAndV1 as icu_provider::DataMarker>::INFO.fallback_config);
40+
let mut fallback_iterator = FALLBACKER.fallback_for(req.id.locale.clone());
41+
loop {
42+
if let Some(payload) = icu_provider::baked::DataStore::get(&Self::DATA_LIST_AND_V1, icu_provider::DataIdentifierBorrowed::for_marker_attributes_and_locale(req.id.marker_attributes, fallback_iterator.get()), req.metadata.attributes_prefix_match) {
43+
metadata.locale = Some(fallback_iterator.take());
44+
break payload;
45+
}
46+
if fallback_iterator.get().is_unknown() {
47+
return Err(icu_provider::DataErrorKind::IdentifierNotFound.with_req(<icu_list::provider::ListAndV1 as icu_provider::DataMarker>::INFO, req));
48+
}
49+
fallback_iterator.step();
50+
}
51+
};
3652
Ok(icu_provider::DataResponse { payload, metadata })
3753
}
3854
}

compiler/rustc_baked_icu_data/src/data/locale_likely_subtags_language_v1.rs.data

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)