Skip to content

Commit

Permalink
Manually implement Default for compatibility with rust 1.61
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Feb 11, 2024
1 parent 1ed0b5e commit 4197a22
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 13 additions & 4 deletions generate-api/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ impl CodeGenerator {

self.generate_variants(f)?;

write!(
f,
r#"
#[allow(clippy::derivable_impls)] // manual impl for rust 1.61 compatibility
impl Default for Locale {{
fn default() -> Self {{
Locale::POSIX
}}
}}
"#,
)?;
Ok(())
}

Expand All @@ -495,7 +507,7 @@ impl CodeGenerator {
/// License note: The Free Software Foundation does not claim any copyright interest in the locale
/// data of the GNU C Library; they believe it is not copyrightable.
#[allow(non_camel_case_types,dead_code)]
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Locale {{
"#,
)?;
Expand Down Expand Up @@ -523,9 +535,6 @@ impl CodeGenerator {
_ => "".to_string(),
};
write!(f, "\n/// `{}`: {}\n", lang, desc)?;
if lang == "POSIX" {
writeln!(f, "\n#[default]\n")?;
}
writeln!(f, "\n{},\n", norm)?;
}

Expand Down
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55115,10 +55115,9 @@ pub mod zu_ZA {
/// License note: The Free Software Foundation does not claim any copyright interest in the locale
/// data of the GNU C Library; they believe it is not copyrightable.
#[allow(non_camel_case_types,dead_code)]
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Locale {
/// `POSIX`: POSIX Standard Locale.
#[default]
POSIX,
/// `aa_DJ`: Afar language locale for Djibouti (Cadu/Laaqo Dialects).
aa_DJ,
Expand Down Expand Up @@ -56838,3 +56837,10 @@ macro_rules! locale_match {
}
}}
}

#[allow(clippy::derivable_impls)] // manual impl for rust 1.61 compatibility
impl Default for Locale {
fn default() -> Self {
Locale::POSIX
}
}

0 comments on commit 4197a22

Please sign in to comment.