Add support for unit structs/variants

finchie
Apr 15, 2025, 10:04 AM
ARB66QTX6V7ZDXQUZQRDQGCUS2LOIB6SKMCL4SK7TVWK3FPBSI3QC

Dependencies

  • [2] YZ6PVVQC Add error handling for common unsupported Rust code
  • [3] QFPQZR4K Refactor `fluent_embed`
  • [4] NO3PDO7P Refactor `fluent_embed` to support structs
  • [5] CESJ4CTO Move macro-specific code into `macro_impl` module
  • [6] F5LG7WEN Emit compilation errors from Fluent source code
  • [7] ROSR4HD5 Parse captured glob as locale
  • [8] JWZT34UC Add `Localize`` trait bound for each field in the derived item
  • [*] XGNME3WR Move `Group::derive_enum` to new `crate::parse_macro` module

Change contents

  • replacement in fluent_embed_derive/src/macro_impl/mod.rs at line 116
    [3.1976][2.817:836]()
    _ => {
    [3.1976]
    [2.836]
    syn::Fields::Unit => Vec::new(),
    syn::Fields::Unnamed(_unnamed_fields) => {
  • replacement in fluent_embed_derive/src/macro_impl/mod.rs at line 131
    [3.2300][2.1193:1393]()
    _ => Err(MacroError::Unsupported(UnsupportedError {
    span: variant.ident.clone(),
    reason: UnsupportedReason::UnnamedFields,
    })),
    [3.2300]
    [3.2330]
    syn::Fields::Unit => Ok(Vec::new()),
    syn::Fields::Unnamed(_unnamed_fields) => {
    Err(MacroError::Unsupported(UnsupportedError {
    span: variant.ident.clone(),
    reason: UnsupportedReason::UnnamedFields,
    }))
    }
  • replacement in fluent_embed_derive/src/macro_impl/derive.rs at line 101
    [3.1538][2.2399:2414]()
    _ => {
    [3.1538]
    [2.2414]
    syn::Fields::Unit => Context {
    reference_kind: ReferenceKind::StructField,
    valid_references: HashSet::new(),
    },
    syn::Fields::Unnamed(_unnamed_fields) => {
  • replacement in fluent_embed_derive/src/macro_impl/derive.rs at line 160
    [3.2579][2.2701:2720]()
    _ => {
    [3.2579]
    [2.2720]
    syn::Fields::Unit => quote!(#variant_pascal_case),
    syn::Fields::Unnamed(_unnamed_fields) => {
  • replacement in fluent_embed_derive/src/macro_impl/derive.rs at line 174
    [3.1973][2.2941:2960]()
    _ => {
    [3.1973]
    [2.2960]
    syn::Fields::Unit => Context {
    reference_kind: ReferenceKind::EnumField,
    valid_references: HashSet::new(),
    },
    syn::Fields::Unnamed(_unnamed_fields) => {