Skip to content

Commit 7d42185

Browse files
committed
fix: Remove leading underscore for variant not using PascalCase
1 parent afcef1b commit 7d42185

File tree

1 file changed

+16
-8
lines changed
  • crates/stackable-versioned-macros/src/codegen/common

1 file changed

+16
-8
lines changed

crates/stackable-versioned-macros/src/codegen/common/mod.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,26 @@ pub(crate) fn format_container_from_ident(ident: &Ident) -> Ident {
5858
///
5959
/// See [`DEPRECATED_FIELD_PREFIX`].
6060
pub(crate) fn remove_deprecated_field_prefix(ident: &Ident) -> Ident {
61-
remove_ident_prefix(ident, DEPRECATED_FIELD_PREFIX)
61+
format_ident!(
62+
"{}",
63+
ident
64+
.to_string()
65+
.trim_start_matches(DEPRECATED_FIELD_PREFIX)
66+
)
6267
}
6368

6469
/// Removes the deprecated prefix from a variant ident.
6570
///
6671
/// See [`DEPRECATED_VARIANT_PREFIX`].
6772
pub(crate) fn remove_deprecated_variant_prefix(ident: &Ident) -> Ident {
68-
remove_ident_prefix(ident, DEPRECATED_VARIANT_PREFIX)
69-
}
70-
71-
/// Removes the provided prefix from an ident and returns the newly created
72-
/// ident.
73-
pub(crate) fn remove_ident_prefix(ident: &Ident, prefix: &str) -> Ident {
74-
format_ident!("{}", ident.to_string().trim_start_matches(prefix))
73+
// NOTE (@Techassi): Currently Clippy only issues a warning for variants
74+
// with underscores in their name. That's why we additionally remove the
75+
// underscore from the ident to use the expected name during code generation.
76+
format_ident!(
77+
"{}",
78+
ident
79+
.to_string()
80+
.trim_start_matches(DEPRECATED_VARIANT_PREFIX)
81+
.trim_start_matches('_')
82+
)
7583
}

0 commit comments

Comments
 (0)