Skip to content

Commit 422b935

Browse files
committed
Add rustc_baked_icu_data crate.
1 parent b0c6527 commit 422b935

File tree

7 files changed

+1243
-0
lines changed

7 files changed

+1243
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "rustc_baked_icu_data"
3+
version = "0.0.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
icu_list = "1.0.0"
8+
icu_provider = "1.0.1"
9+
litemap = "0.6.0"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @generated
2+
impl AnyProvider for BakedDataProvider {
3+
fn load_any(&self, key: DataKey, req: DataRequest) -> Result<AnyResponse, DataError> {
4+
const ANDLISTV1MARKER: ::icu_provider::DataKeyHash =
5+
::icu_list::provider::AndListV1Marker::KEY.hashed();
6+
#[allow(clippy::match_single_binding)]
7+
match key.hashed() {
8+
ANDLISTV1MARKER => list::and_v1::DATA
9+
.get_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse())
10+
.copied()
11+
.map(AnyPayload::from_static_ref)
12+
.ok_or(DataErrorKind::MissingLocale),
13+
_ => Err(DataErrorKind::MissingDataKey),
14+
}
15+
.map_err(|e| e.with_req(key, req))
16+
.map(|payload| AnyResponse { payload: Some(payload), metadata: Default::default() })
17+
}
18+
}

compiler/rustc_baked_icu_data/src/data/list/and_v1.rs

Lines changed: 1160 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @generated
2+
pub mod and_v1;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @generated
2+
mod list;
3+
/// This data provider was programmatically generated by [`icu_datagen`](
4+
/// https://unicode-org.github.io/icu4x-docs/doc/icu_datagen/enum.Out.html#variant.Module).
5+
#[non_exhaustive]
6+
pub struct BakedDataProvider;
7+
use ::icu_provider::prelude::*;
8+
impl DataProvider<::icu_list::provider::AndListV1Marker> for BakedDataProvider {
9+
fn load(
10+
&self,
11+
req: DataRequest,
12+
) -> Result<DataResponse<::icu_list::provider::AndListV1Marker>, DataError> {
13+
Ok(DataResponse {
14+
metadata: Default::default(),
15+
payload: Some(DataPayload::from_owned(zerofrom::ZeroFrom::zero_from(
16+
*list::and_v1::DATA
17+
.get_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse())
18+
.ok_or_else(|| {
19+
DataErrorKind::MissingLocale
20+
.with_req(::icu_list::provider::AndListV1Marker::KEY, req)
21+
})?,
22+
))),
23+
})
24+
}
25+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Baked ICU data for eager translation support.
2+
//!
3+
#![allow(elided_lifetimes_in_paths)]
4+
5+
// generated with:
6+
// ```text
7+
// icu4x-datagen -W --pretty --fingerprint --use-separate-crates --cldr-tag latest --icuexport-tag latest \
8+
// --format mod -l en es fr it ja pt ru tr zh-Hans zh-Hant -k list/and@1 -o src/data
9+
// ```
10+
11+
mod data;
12+
13+
pub use data::BakedDataProvider;
14+
15+
pub fn baked_data_provider() -> BakedDataProvider {
16+
data::BakedDataProvider
17+
}

src/tools/tidy/src/deps.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
132132
"hashbrown",
133133
"hermit-abi",
134134
"humantime",
135+
"icu_list",
136+
"icu_locid",
137+
"icu_provider",
138+
"icu_provider_macros",
135139
"if_chain",
136140
"indexmap",
137141
"instant",
@@ -144,6 +148,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
144148
"libc",
145149
"libloading",
146150
"libz-sys",
151+
"litemap",
147152
"lock_api",
148153
"log",
149154
"matchers",
@@ -252,9 +257,16 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
252257
"winapi-i686-pc-windows-gnu",
253258
"winapi-util",
254259
"winapi-x86_64-pc-windows-gnu",
260+
"writeable",
255261
// this is a false-positive: it's only used by rustfmt, but because it's enabled through a
256262
// feature, tidy thinks it's used by rustc as well.
257263
"yansi-term",
264+
"yoke",
265+
"yoke-derive",
266+
"zerofrom",
267+
"zerofrom-derive",
268+
"zerovec",
269+
"zerovec-derive",
258270
];
259271

260272
const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[

0 commit comments

Comments
 (0)