From 2de8fc022e1a527c9dbf49c90b140a7ea2c7526c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 14:54:26 +0300 Subject: [PATCH 01/13] chore: Default to MSRV aware resolver when possible/where supported --- .cargo/config.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..4a6a1abd --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[resolver] +incompatible-rust-versions = "fallback" From d4df0f315994155c93bccb22e4cf96a332c7830f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 14:48:59 +0300 Subject: [PATCH 02/13] deps(fluent-pseudo): Limit regex crate version to maintain msrv status quo --- fluent-pseudo/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fluent-pseudo/Cargo.toml b/fluent-pseudo/Cargo.toml index 9ee4063b..0dff9b1b 100644 --- a/fluent-pseudo/Cargo.toml +++ b/fluent-pseudo/Cargo.toml @@ -24,4 +24,4 @@ include = [ ] [dependencies] -regex = "1" +regex = "1.9" From c5885ed537c73aa1b1f19103a90b50fcbf7c3a3c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 12:54:43 +0300 Subject: [PATCH 03/13] refactor(fluent-pseudo): Use once_cell to avoid unsafe mutable static without bumping MSRV This can be updated to use the *std* implementation once our MSRV can be 1.70 or newer. For now this conservatively maintains the lower MSRV while dodging the undefined behavior of a mutable reference to a mutable static. Technically what we were doing would work, but relying on undefined behavior that we were only bending now breaking isn't a great practice. Two less unsafe blocks. Note the once_cell 1.21.x release series requires 1.66.0, which is a bump up from what fluent-pseudo currently needs. --- fluent-pseudo/Cargo.toml | 1 + fluent-pseudo/src/lib.rs | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fluent-pseudo/Cargo.toml b/fluent-pseudo/Cargo.toml index 0dff9b1b..9267b61e 100644 --- a/fluent-pseudo/Cargo.toml +++ b/fluent-pseudo/Cargo.toml @@ -25,3 +25,4 @@ include = [ [dependencies] regex = "1.9" +once_cell = "1.20" diff --git a/fluent-pseudo/src/lib.rs b/fluent-pseudo/src/lib.rs index 505473e2..4f5af15c 100644 --- a/fluent-pseudo/src/lib.rs +++ b/fluent-pseudo/src/lib.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use regex::Captures; use regex::Regex; use std::borrow::Cow; @@ -20,8 +21,8 @@ static FLIPPED_CAPS_MAP: &[char] = &[ '⊥', '∩', 'Ʌ', 'M', 'X', '⅄', 'Z', ]; -static mut RE_EXCLUDED: Option = None; -static mut RE_AZ: Option = None; +static RE_EXCLUDED: Lazy = Lazy::new(|| Regex::new(r"&[#\w]+;|<\s*.+?\s*>").unwrap()); +static RE_AZ: Lazy = Lazy::new(|| Regex::new(r"[a-zA-Z]").unwrap()); pub fn transform_dom(s: &str, flipped: bool, elongate: bool, with_markers: bool) -> Cow { // Exclude access-keys and other single-char messages @@ -30,15 +31,12 @@ pub fn transform_dom(s: &str, flipped: bool, elongate: bool, with_markers: bool) } // XML entities (‪) and XML tags. - let re_excluded = - unsafe { RE_EXCLUDED.get_or_insert_with(|| Regex::new(r"&[#\w]+;|<\s*.+?\s*>").unwrap()) }; - let mut result = Cow::from(s); let mut pos = 0; let mut diff = 0; - for cap in re_excluded.captures_iter(s) { + for cap in RE_EXCLUDED.captures_iter(s) { let capture = cap.get(0).unwrap(); let sub_len = capture.start() - pos; @@ -65,15 +63,13 @@ pub fn transform_dom(s: &str, flipped: bool, elongate: bool, with_markers: bool) } pub fn transform(s: &str, flipped: bool, elongate: bool) -> Cow { - let re_az = unsafe { RE_AZ.get_or_insert_with(|| Regex::new(r"[a-zA-Z]").unwrap()) }; - let (small_map, caps_map) = if flipped { (FLIPPED_SMALL_MAP, FLIPPED_CAPS_MAP) } else { (TRANSFORM_SMALL_MAP, TRANSFORM_CAPS_MAP) }; - re_az.replace_all(s, |caps: &Captures| { + RE_AZ.replace_all(s, |caps: &Captures| { let ch = caps[0].chars().next().unwrap(); let cc = ch as u8; if (97..=122).contains(&cc) { From 2eb07ffca097bbeadf65c11e4205eb15c99f1399 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 21 May 2025 00:47:56 +0300 Subject: [PATCH 04/13] deps(fluent-fallback): Bump once_cell to 1.21 --- fluent-fallback/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fluent-fallback/Cargo.toml b/fluent-fallback/Cargo.toml index f9240a6b..adee76bc 100644 --- a/fluent-fallback/Cargo.toml +++ b/fluent-fallback/Cargo.toml @@ -22,7 +22,7 @@ rustc-hash.workspace = true unic-langid.workspace = true async-trait = "0.1" chunky-vec = "0.1" -once_cell = "1.19" +once_cell = "1.21" pin-cell = "0.2" [dev-dependencies] From eee924b59ee9b945e4f28c912f953a0e053b162d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 14:51:31 +0300 Subject: [PATCH 05/13] deps(fluent-pseudo): Bump MSRV to 1.65.0 to for fresh dependencies This is still lower than the workspace MSRV for the other main crates (which is 1.67.0 as of now) so 1.65.0 shouldn't be a hinderance to anybody and allows current versions of both regex and once_cell. --- fluent-pseudo/Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fluent-pseudo/Cargo.toml b/fluent-pseudo/Cargo.toml index 9267b61e..6e829b0d 100644 --- a/fluent-pseudo/Cargo.toml +++ b/fluent-pseudo/Cargo.toml @@ -6,7 +6,7 @@ a localization system designed to unleash the entire expressive power of natural """ version = "0.3.2" edition.workspace = true -rust-version = "1.64.0" +rust-version = "1.65.0" homepage.workspace = true repository.workspace = true license.workspace = true @@ -24,5 +24,5 @@ include = [ ] [dependencies] -regex = "1.9" -once_cell = "1.20" +regex = "1.11" +once_cell = "1.21" From 3444df6159540f71abbcc767c7bd72c4498e6787 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 14:56:31 +0300 Subject: [PATCH 06/13] deps(fluent-bundle): Bump non-breaking dependency to current series --- fluent-bundle/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fluent-bundle/Cargo.toml b/fluent-bundle/Cargo.toml index 02c72737..549bf77e 100644 --- a/fluent-bundle/Cargo.toml +++ b/fluent-bundle/Cargo.toml @@ -30,7 +30,7 @@ intl_pluralrules.workspace = true rustc-hash.workspace = true unic-langid.workspace = true intl-memoizer = { version = "0.5.2", path = "../intl-memoizer" } -self_cell = "1.0" +self_cell = "1.2" smallvec = "1.13" [dev-dependencies] From a85f69ab4398e55e1cd473427c1ecd810b63ee44 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 14:56:31 +0300 Subject: [PATCH 07/13] c(fluent-bundle): Bump rand dependency and update usage for 0.9.x --- fluent-bundle/Cargo.toml | 2 +- fluent-bundle/tests/resolver_fixtures.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fluent-bundle/Cargo.toml b/fluent-bundle/Cargo.toml index 549bf77e..2a53e95d 100644 --- a/fluent-bundle/Cargo.toml +++ b/fluent-bundle/Cargo.toml @@ -38,7 +38,7 @@ criterion.workspace = true iai.workspace = true serde = { workspace = true, features = ["derive"] } unic-langid = { workspace = true, features = ["macros"] } -rand = "0.8" +rand = "0.9" serde_yaml = "0.9" [features] diff --git a/fluent-bundle/tests/resolver_fixtures.rs b/fluent-bundle/tests/resolver_fixtures.rs index e242a390..711efba2 100644 --- a/fluent-bundle/tests/resolver_fixtures.rs +++ b/fluent-bundle/tests/resolver_fixtures.rs @@ -10,8 +10,8 @@ use fluent_bundle::resolver::ResolverError; use fluent_bundle::FluentArgs; use fluent_bundle::FluentError; use fluent_bundle::{FluentBundle, FluentResource, FluentValue}; -use rand::distributions::Alphanumeric; -use rand::{thread_rng, Rng}; +use rand::distr::Alphanumeric; +use rand::{rng, Rng}; use unic_langid::LanguageIdentifier; use helpers::*; @@ -72,7 +72,7 @@ impl Scope { } fn generate_random_hash() -> String { - let mut rng = thread_rng(); + let mut rng = rng(); let chars: String = iter::repeat(()) .map(|()| rng.sample(Alphanumeric)) .map(char::from) From 9014c2fb151e0a9a4480374b06dd893648cb3adb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 19 May 2025 15:12:42 +0300 Subject: [PATCH 08/13] deps(workspace): Bump non-breaking dependencies --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 883ad909..72f169cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ rustc-hash = "2" serde = "1.0" serde_json = "1.0" thiserror = "2.0" -tokio = "1.0" +tokio = "1.38" unic-langid = "0.9" fluent-bundle = { version = "0.15.3", path = "fluent-bundle" } From a1fed786ce1fd3954e81ee0b7cf39cffcb3e229d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 20 May 2025 15:40:39 +0300 Subject: [PATCH 09/13] chore: Add Typos configuration --- Cargo.toml | 21 +++++++++++++++++++++ fluent-bundle/tests/builtins.rs | 2 ++ 2 files changed, 23 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 72f169cf..1318399e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,3 +47,24 @@ fluent-bundle = { version = "0.15.3", path = "fluent-bundle" } fluent-fallback = { version = "0.7.1", path = "fluent-fallback" } fluent-pseudo = { version = "0.3.2", path = "fluent-pseudo" } fluent-syntax = { version = "0.11.1", path = "fluent-syntax" } + +[workspace.metadata.typos.default] +locale = "en-us" +extend-ignore-re = [ + "(?s)(#|//|/\\*)\\s*typos: ignore start.*?\\n\\s*(#|//|/\\*)\\s*typos: ignore end", +] + +[workspace.metadata.typos.default.extend-words] +travelled = "travelled" # sadly part of a public API and fixing would be a breaking change +nd = "nd" # appears frequently in inline test messages + +[workspace.metadata.typos.files] +ignore-hidden = false +extend-exclude = [ + "/.git", + "fluent-bundle/benches/**/*.ftl", + "fluent-bundle/examples/**/*.ftl", + "fluent-syntax/tests/fixtures/**/*.ftl", + "fluent-syntax/tests/fixtures/**/*.json", + "fluent-testing/resources/**/*.ftl", +] diff --git a/fluent-bundle/tests/builtins.rs b/fluent-bundle/tests/builtins.rs index 092c94ac..35fb299f 100644 --- a/fluent-bundle/tests/builtins.rs +++ b/fluent-bundle/tests/builtins.rs @@ -4,6 +4,7 @@ use fluent_syntax::ast::Pattern; #[test] fn test_builtin_number() { // 1. Create bundle + // typos: ignore start let ftl_string = String::from( r#" count = { NUMBER($num, type: "cardinal") -> @@ -17,6 +18,7 @@ order = { NUMBER($num, type: "ordinal") -> [few] {$num}rd } "#, + // typos: ignore end ); let mut bundle = FluentBundle::default(); From 6cf47b6e67a42eb237a5fcb4317b786671763220 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 20 May 2025 15:40:39 +0300 Subject: [PATCH 10/13] chore: Normalize minor locale variations in comments --- fluent-bundle/examples/custom_type.rs | 2 +- fluent-fallback/examples/simple-fallback.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fluent-bundle/examples/custom_type.rs b/fluent-bundle/examples/custom_type.rs index 97bc1f57..b249ff03 100644 --- a/fluent-bundle/examples/custom_type.rs +++ b/fluent-bundle/examples/custom_type.rs @@ -8,7 +8,7 @@ // // Lastly, we'll also create a new formatter which will be memoizable. // -// The type and its options are modelled after ECMA402 Intl.DateTimeFormat. +// The type and its options are modeled after ECMA402 Intl.DateTimeFormat. use intl_memoizer::Memoizable; use unic_langid::LanguageIdentifier; diff --git a/fluent-fallback/examples/simple-fallback.rs b/fluent-fallback/examples/simple-fallback.rs index 33fc4e82..08d4cd66 100644 --- a/fluent-fallback/examples/simple-fallback.rs +++ b/fluent-fallback/examples/simple-fallback.rs @@ -32,7 +32,7 @@ use rustc_hash::FxHashSet; use unic_langid::{langid, LanguageIdentifier}; /// This helper struct holds the scheme for converting -/// resource paths into full paths. It is used to customise +/// resource paths into full paths. It is used to customize /// `fluent-fallback::SyncLocalization`. struct Bundles { res_path_scheme: PathBuf, From c83e5eb30588bf538284f724d3a275a61a10e279 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 21 May 2025 01:58:05 +0300 Subject: [PATCH 11/13] style: Normalize sort of derives --- fluent-bundle/examples/custom_type.rs | 6 +++--- fluent-bundle/src/errors.rs | 4 ++-- fluent-bundle/src/resolver/errors.rs | 4 ++-- fluent-bundle/src/types/number.rs | 10 ++++----- fluent-bundle/tests/custom_types.rs | 6 +++--- fluent-bundle/tests/helpers/mod.rs | 22 +++++++++---------- fluent-fallback/src/errors.rs | 2 +- fluent-fallback/src/types.rs | 8 +++---- fluent-resmgr/src/resource_manager.rs | 2 +- fluent-syntax/src/ast/helper.rs | 2 +- fluent-syntax/src/ast/mod.rs | 30 +++++++++++++------------- fluent-syntax/src/parser/comment.rs | 2 +- fluent-syntax/src/parser/errors.rs | 4 ++-- fluent-syntax/src/serializer.rs | 4 ++-- intl-memoizer/examples/numberformat.rs | 2 +- 15 files changed, 54 insertions(+), 54 deletions(-) diff --git a/fluent-bundle/examples/custom_type.rs b/fluent-bundle/examples/custom_type.rs index b249ff03..71c0f882 100644 --- a/fluent-bundle/examples/custom_type.rs +++ b/fluent-bundle/examples/custom_type.rs @@ -21,7 +21,7 @@ use fluent_bundle::{FluentArgs, FluentBundle, FluentResource, FluentValue}; // - timeStyle // // with an enum of allowed values. -#[derive(Debug, Default, PartialEq, Eq, Clone, Hash)] +#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)] enum DateTimeStyleValue { Full, Long, @@ -49,7 +49,7 @@ impl From<&FluentValue<'_>> for DateTimeStyleValue { } } -#[derive(Debug, PartialEq, Eq, Default, Clone, Hash)] +#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)] struct DateTimeOptions { pub date_style: DateTimeStyleValue, pub time_style: DateTimeStyleValue, @@ -84,7 +84,7 @@ impl From<&FluentArgs<'_>> for DateTimeOptions { // Our new custom type will store a value as an epoch number, // and the options. -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] struct DateTime { epoch: usize, options: DateTimeOptions, diff --git a/fluent-bundle/src/errors.rs b/fluent-bundle/src/errors.rs index 58b1754b..df4af279 100644 --- a/fluent-bundle/src/errors.rs +++ b/fluent-bundle/src/errors.rs @@ -2,7 +2,7 @@ use crate::resolver::ResolverError; use fluent_syntax::parser::ParserError; use std::error::Error; -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] pub enum EntryKind { Message, Term, @@ -23,7 +23,7 @@ impl std::fmt::Display for EntryKind { /// /// It contains three main types of errors that may come up /// during runtime use of the fluent-bundle crate. -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] pub enum FluentError { /// An error which occurs when /// [`FluentBundle::add_resource`](crate::bundle::FluentBundle::add_resource) diff --git a/fluent-bundle/src/resolver/errors.rs b/fluent-bundle/src/resolver/errors.rs index 7606faba..dc716d98 100644 --- a/fluent-bundle/src/resolver/errors.rs +++ b/fluent-bundle/src/resolver/errors.rs @@ -4,7 +4,7 @@ use std::error::Error; /// Maps an [`InlineExpression`] into the kind of reference, with owned strings /// that identify the expression. This makes it so that the [`InlineExpression`] can /// be used to generate an error string. -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] pub enum ReferenceKind { Function { id: String, @@ -49,7 +49,7 @@ where /// Errors generated during the process of resolving a fluent message into a string. /// This process takes place in the `write` method of the `WriteValue` trait. -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] pub enum ResolverError { Reference(ReferenceKind), NoValue(String), diff --git a/fluent-bundle/src/types/number.rs b/fluent-bundle/src/types/number.rs index 8cdeb26e..12aac89f 100644 --- a/fluent-bundle/src/types/number.rs +++ b/fluent-bundle/src/types/number.rs @@ -8,7 +8,7 @@ use intl_pluralrules::operands::PluralOperands; use crate::args::FluentArgs; use crate::types::FluentValue; -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] pub enum FluentNumberType { #[default] Cardinal, @@ -25,7 +25,7 @@ impl From<&str> for FluentNumberType { } } -#[derive(Debug, Copy, Clone, Default, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] pub enum FluentNumberStyle { #[default] Decimal, @@ -44,7 +44,7 @@ impl From<&str> for FluentNumberStyle { } } -#[derive(Debug, Copy, Clone, Default, Hash, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] pub enum FluentNumberCurrencyDisplayStyle { #[default] Symbol, @@ -63,7 +63,7 @@ impl From<&str> for FluentNumberCurrencyDisplayStyle { } } -#[derive(Debug, Clone, Hash, PartialEq, Eq)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct FluentNumberOptions { pub r#type: FluentNumberType, pub style: FluentNumberStyle, @@ -134,7 +134,7 @@ impl FluentNumberOptions { } } -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] pub struct FluentNumber { pub value: f64, pub options: FluentNumberOptions, diff --git a/fluent-bundle/tests/custom_types.rs b/fluent-bundle/tests/custom_types.rs index 5b5b66f7..594df9af 100644 --- a/fluent-bundle/tests/custom_types.rs +++ b/fluent-bundle/tests/custom_types.rs @@ -47,7 +47,7 @@ fn fluent_custom_type() { #[test] fn fluent_date_time_builtin() { - #[derive(Debug, Default, PartialEq, Clone)] + #[derive(Clone, Debug, Default, PartialEq)] enum DateTimeStyleValue { Full, Long, @@ -73,7 +73,7 @@ fn fluent_date_time_builtin() { } } - #[derive(Debug, PartialEq, Default, Clone)] + #[derive(Clone, Debug, Default, PartialEq)] struct DateTimeOptions { pub date_style: DateTimeStyleValue, pub time_style: DateTimeStyleValue, @@ -99,7 +99,7 @@ fn fluent_date_time_builtin() { } } - #[derive(Debug, PartialEq, Clone)] + #[derive(Clone, Debug, PartialEq)] struct DateTime { epoch: usize, options: DateTimeOptions, diff --git a/fluent-bundle/tests/helpers/mod.rs b/fluent-bundle/tests/helpers/mod.rs index c5e20cf0..5a4015f6 100644 --- a/fluent-bundle/tests/helpers/mod.rs +++ b/fluent-bundle/tests/helpers/mod.rs @@ -88,7 +88,7 @@ pub fn get_defaults(path: &str) -> Result { Ok(serde_yaml::from_str(&s).expect("Parsing YAML failed.")) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestBundle { pub name: Option, @@ -102,7 +102,7 @@ pub struct TestBundle { pub errors: Vec, } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestResource { pub name: Option, @@ -111,7 +111,7 @@ pub struct TestResource { pub source: String, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestSetup { #[serde(skip_serializing_if = "Vec::is_empty", default)] @@ -120,7 +120,7 @@ pub struct TestSetup { pub resources: Vec, } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestError { #[serde(rename = "type")] @@ -128,7 +128,7 @@ pub struct TestError { pub desc: Option, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] #[serde(untagged)] pub enum TestArgumentValue { @@ -136,7 +136,7 @@ pub enum TestArgumentValue { Number(f64), } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestAssert { pub bundle: Option, @@ -149,7 +149,7 @@ pub struct TestAssert { pub missing: Option, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct Test { pub name: String, @@ -163,7 +163,7 @@ pub struct Test { pub asserts: Vec, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestSuite { pub name: String, @@ -180,13 +180,13 @@ pub struct TestSuite { pub suites: Vec, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestFixture { pub suites: Vec, } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct BundleDefaults { #[serde(rename = "useIsolating")] @@ -195,7 +195,7 @@ pub struct BundleDefaults { pub locales: Option>, } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct TestDefaults { pub bundle: BundleDefaults, diff --git a/fluent-fallback/src/errors.rs b/fluent-fallback/src/errors.rs index 704bc84f..335d7611 100644 --- a/fluent-fallback/src/errors.rs +++ b/fluent-fallback/src/errors.rs @@ -2,7 +2,7 @@ use fluent_bundle::FluentError; use std::error::Error; use unic_langid::LanguageIdentifier; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Eq, PartialEq)] pub enum LocalizationError { Bundle { error: FluentError, diff --git a/fluent-fallback/src/types.rs b/fluent-fallback/src/types.rs index ad424dad..93b33abc 100644 --- a/fluent-fallback/src/types.rs +++ b/fluent-fallback/src/types.rs @@ -16,19 +16,19 @@ impl<'l> From<&'l str> for L10nKey<'l> { } } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct L10nAttribute<'l> { pub name: Cow<'l, str>, pub value: Cow<'l, str>, } -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct L10nMessage<'l> { pub value: Option>, pub attributes: Vec>, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum ResourceType { /// This is a required resource. /// @@ -53,7 +53,7 @@ pub enum ResourceType { } /// A resource identifier for a localization resource. -#[derive(Debug, Clone)] +#[derive(Clone, Debug)] pub struct ResourceId { /// The resource identifier. pub value: String, diff --git a/fluent-resmgr/src/resource_manager.rs b/fluent-resmgr/src/resource_manager.rs index 9f2cfc57..84b53dfb 100644 --- a/fluent-resmgr/src/resource_manager.rs +++ b/fluent-resmgr/src/resource_manager.rs @@ -144,7 +144,7 @@ impl ResourceManager { } /// Errors generated during the process of retrieving the localization resources -#[derive(Error, Debug)] +#[derive(Debug, Error)] pub enum ResourceManagerError { /// Error while reading the resource file #[error("{0}")] diff --git a/fluent-syntax/src/ast/helper.rs b/fluent-syntax/src/ast/helper.rs index 23851301..89708ee0 100644 --- a/fluent-syntax/src/ast/helper.rs +++ b/fluent-syntax/src/ast/helper.rs @@ -5,7 +5,7 @@ use super::Comment; // This is a helper struct used to properly deserialize referential // JSON comments which are single continuous String, into a vec of // content slices. -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))] pub enum CommentDef { diff --git a/fluent-syntax/src/ast/mod.rs b/fluent-syntax/src/ast/mod.rs index 273aceaf..51d098bd 100644 --- a/fluent-syntax/src/ast/mod.rs +++ b/fluent-syntax/src/ast/mod.rs @@ -111,7 +111,7 @@ use serde::{Deserialize, Serialize}; /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Resource { pub body: Vec>, @@ -193,7 +193,7 @@ pub struct Resource { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum Entry { @@ -253,7 +253,7 @@ pub enum Entry { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Message { pub id: Identifier, @@ -307,7 +307,7 @@ pub struct Message { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Term { pub id: Identifier, @@ -387,7 +387,7 @@ pub struct Term { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Pattern { pub elements: Vec>, @@ -464,7 +464,7 @@ pub struct Pattern { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum PatternElement { @@ -535,7 +535,7 @@ pub enum PatternElement { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Attribute { pub id: Identifier, @@ -584,7 +584,7 @@ pub struct Attribute { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Identifier { pub name: S, @@ -667,7 +667,7 @@ pub struct Identifier { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub struct Variant { @@ -752,7 +752,7 @@ pub struct Variant { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum VariantKey { @@ -798,7 +798,7 @@ pub enum VariantKey { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(from = "helper::CommentDef"))] pub struct Comment { @@ -879,7 +879,7 @@ pub struct Comment { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone, Default)] +#[derive(Clone, Debug, Default, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub struct CallArguments { @@ -948,7 +948,7 @@ pub struct CallArguments { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub struct NamedArgument { @@ -1004,7 +1004,7 @@ pub struct NamedArgument { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum InlineExpression { @@ -1434,7 +1434,7 @@ pub enum InlineExpression { /// } /// ); /// ``` -#[derive(Debug, PartialEq, Clone)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))] pub enum Expression { diff --git a/fluent-syntax/src/parser/comment.rs b/fluent-syntax/src/parser/comment.rs index 1e30fc72..253e168e 100644 --- a/fluent-syntax/src/parser/comment.rs +++ b/fluent-syntax/src/parser/comment.rs @@ -1,7 +1,7 @@ use super::{core::Parser, core::Result, Slice}; use crate::ast; -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Clone, Copy, Debug, PartialEq)] pub(super) enum Level { None = 0, Regular = 1, diff --git a/fluent-syntax/src/parser/errors.rs b/fluent-syntax/src/parser/errors.rs index 9bf48d71..9377dad6 100644 --- a/fluent-syntax/src/parser/errors.rs +++ b/fluent-syntax/src/parser/errors.rs @@ -92,7 +92,7 @@ use thiserror::Error; /// The information contained in the `ParserError` should allow the tooling /// to display rich contextual annotations of the error slice, using /// crates such as `annotate-snippers`. -#[derive(Error, Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, Error, PartialEq)] #[error("{}", self.kind)] pub struct ParserError { /// Precise location of where the parser encountered the error. @@ -122,7 +122,7 @@ macro_rules! error { } /// Kind of an error associated with the [`ParserError`]. -#[derive(Error, Debug, PartialEq, Eq, Clone)] +#[derive(Clone, Debug, Eq, Error, PartialEq)] pub enum ErrorKind { #[error("Expected a token starting with \"{0}\"")] ExpectedToken(char), diff --git a/fluent-syntax/src/serializer.rs b/fluent-syntax/src/serializer.rs index a3442429..30f5ba97 100644 --- a/fluent-syntax/src/serializer.rs +++ b/fluent-syntax/src/serializer.rs @@ -386,7 +386,7 @@ fn is_select_expr<'s, S: Slice<'s>>(expr: &Expression) -> bool { } /// Options for serializing an abstract syntax tree. -#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct Options { /// Whether invalid text fragments should be serialized, too. pub with_junk: bool, @@ -397,7 +397,7 @@ struct State { wrote_non_junk_entry: bool, } -#[derive(Debug, Clone, Default)] +#[derive(Clone, Debug, Default)] struct TextWriter { buffer: String, indent_level: usize, diff --git a/intl-memoizer/examples/numberformat.rs b/intl-memoizer/examples/numberformat.rs index 793c890c..8020da49 100644 --- a/intl-memoizer/examples/numberformat.rs +++ b/intl-memoizer/examples/numberformat.rs @@ -1,7 +1,7 @@ use intl_memoizer::{IntlMemoizer, Memoizable}; use unic_langid::LanguageIdentifier; -#[derive(Clone, Hash, PartialEq, Eq)] +#[derive(Clone, Eq, Hash, PartialEq)] struct NumberFormatOptions { minimum_fraction_digits: usize, maximum_fraction_digits: usize, From 16ed702a4b6c6341b1b9d4861e5cc2726f87aadc Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 20 May 2025 16:44:26 +0300 Subject: [PATCH 12/13] deps: Move all commmon dependencies to workspace to normalize versions --- Cargo.toml | 2 ++ fluent-bundle/Cargo.toml | 2 +- fluent-fallback/Cargo.toml | 2 +- fluent-pseudo/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1318399e..677ceed5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ fluent-langneg = "0.13" futures = "0.3" iai = "0.1" intl_pluralrules = "7.0" +once_cell = "1.21" rustc-hash = "2" serde = "1.0" serde_json = "1.0" @@ -47,6 +48,7 @@ fluent-bundle = { version = "0.15.3", path = "fluent-bundle" } fluent-fallback = { version = "0.7.1", path = "fluent-fallback" } fluent-pseudo = { version = "0.3.2", path = "fluent-pseudo" } fluent-syntax = { version = "0.11.1", path = "fluent-syntax" } +intl-memoizer = { version = "0.5.2", path = "intl-memoizer" } [workspace.metadata.typos.default] locale = "en-us" diff --git a/fluent-bundle/Cargo.toml b/fluent-bundle/Cargo.toml index 2a53e95d..75fcaef5 100644 --- a/fluent-bundle/Cargo.toml +++ b/fluent-bundle/Cargo.toml @@ -29,7 +29,7 @@ fluent-syntax.workspace = true intl_pluralrules.workspace = true rustc-hash.workspace = true unic-langid.workspace = true -intl-memoizer = { version = "0.5.2", path = "../intl-memoizer" } +intl-memoizer.workspace = true self_cell = "1.2" smallvec = "1.13" diff --git a/fluent-fallback/Cargo.toml b/fluent-fallback/Cargo.toml index adee76bc..fc60c0f7 100644 --- a/fluent-fallback/Cargo.toml +++ b/fluent-fallback/Cargo.toml @@ -22,7 +22,7 @@ rustc-hash.workspace = true unic-langid.workspace = true async-trait = "0.1" chunky-vec = "0.1" -once_cell = "1.21" +once_cell.workspace = true pin-cell = "0.2" [dev-dependencies] diff --git a/fluent-pseudo/Cargo.toml b/fluent-pseudo/Cargo.toml index 6e829b0d..9ed8e479 100644 --- a/fluent-pseudo/Cargo.toml +++ b/fluent-pseudo/Cargo.toml @@ -24,5 +24,5 @@ include = [ ] [dependencies] +once_cell.workspace = true regex = "1.11" -once_cell = "1.21" From cd5c60cecf1700e16cd23d7fb2bb7baef6af37e4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 21 May 2025 13:06:28 +0300 Subject: [PATCH 13/13] docs: Update changelogs with currently merged changes --- fluent-bundle/CHANGELOG.md | 9 ++++++++- fluent-fallback/CHANGELOG.md | 6 ++++-- fluent-pseudo/CHANGELOG.md | 6 ++++-- fluent-resmgr/CHANGELOG.md | 5 +++-- fluent-syntax/CHANGELOG.md | 6 ++++-- fluent-testing/CHANGELOG.md | 3 +-- fluent/CHANGELOG.md | 3 +-- intl-memoizer/CHANGELOG.md | 3 +-- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/fluent-bundle/CHANGELOG.md b/fluent-bundle/CHANGELOG.md index cf626d7d..4e25f1cc 100644 --- a/fluent-bundle/CHANGELOG.md +++ b/fluent-bundle/CHANGELOG.md @@ -1,7 +1,14 @@ # Changelog ## Unreleased - - Bump `self_cell` to 1.x + - Implement NUMBER builtin + - Improve examples + - Refactor to remove unnecessary named lifetimes + - Cleanup docs + - Satiate Clippy + - Bump `smallvec` to 1.13 + - Bump `rand` to 0.9 + - Bump `self_cell` to 1.2 - Bump `serde_yaml` to 0.9 ## fluent-bundle 0.15.3 (March 16, 2024) diff --git a/fluent-fallback/CHANGELOG.md b/fluent-fallback/CHANGELOG.md index 739765a4..cc567fb8 100644 --- a/fluent-fallback/CHANGELOG.md +++ b/fluent-fallback/CHANGELOG.md @@ -1,8 +1,10 @@ # Changelog ## Unreleased - - - … + - Refactor to remove unnecessary named lifetimes + - Cleanup docs + - Satiate Clippy + - Bump `once_cell` to 1.21 ## fluent-fallback 0.7.1 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers diff --git a/fluent-pseudo/CHANGELOG.md b/fluent-pseudo/CHANGELOG.md index 75ed61eb..97a05677 100644 --- a/fluent-pseudo/CHANGELOG.md +++ b/fluent-pseudo/CHANGELOG.md @@ -1,8 +1,10 @@ # Changelog ## Unreleased - - - … + - Eliminate unsafe block using `once_cell` instead of undefined behavior of mutable reference to mutable static + - Cleanup docs + - Satiate Clippy + - Bump `regex` to 1.11 ## fluent-pseudo 0.3.2 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers diff --git a/fluent-resmgr/CHANGELOG.md b/fluent-resmgr/CHANGELOG.md index 671ba65a..32b3dc2f 100644 --- a/fluent-resmgr/CHANGELOG.md +++ b/fluent-resmgr/CHANGELOG.md @@ -1,8 +1,9 @@ # Changelog ## Unreleased - - - … + - Cleanup docs + - Satiate Clippy + - Bump `elsa` to 1.10 ## fluent-resmgr 0.0.7 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers diff --git a/fluent-syntax/CHANGELOG.md b/fluent-syntax/CHANGELOG.md index 592d10ea..435fb448 100644 --- a/fluent-syntax/CHANGELOG.md +++ b/fluent-syntax/CHANGELOG.md @@ -1,8 +1,10 @@ # Changelog ## Unreleased - - Add module `serializer`. - - … + - Add module `serializer` + - De-ambiguate dependencies vs. features + - Cleanup docs + - Satiate Clippy ## fluent-syntax 0.11.1 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers diff --git a/fluent-testing/CHANGELOG.md b/fluent-testing/CHANGELOG.md index 40aae598..d4ed5788 100644 --- a/fluent-testing/CHANGELOG.md +++ b/fluent-testing/CHANGELOG.md @@ -1,8 +1,7 @@ # Changelog ## Unreleased - - - … + - Cleanup docs ## fluent-testing 0.0.4 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers diff --git a/fluent/CHANGELOG.md b/fluent/CHANGELOG.md index 8f1e2b28..02eb36bd 100644 --- a/fluent/CHANGELOG.md +++ b/fluent/CHANGELOG.md @@ -1,8 +1,7 @@ # Changelog ## Unreleased - - - … + - Cleanup docs ## fluent 0.16.1 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers diff --git a/intl-memoizer/CHANGELOG.md b/intl-memoizer/CHANGELOG.md index b5adfd32..3314a61e 100644 --- a/intl-memoizer/CHANGELOG.md +++ b/intl-memoizer/CHANGELOG.md @@ -1,8 +1,7 @@ # Changelog ## Unreleased - - - … + - Cleanup docs ## intl-memoizer 0.5.2 (March 16, 2024) - This is a 'safe harbor' release prior to bringing on non-Mozilla community maintainers