Skip to content

Commit 360ae34

Browse files
committed
fix(macro): Fix rename some magic methods
1 parent b6cb935 commit 360ae34

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

crates/macros/src/parsing.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,23 @@ impl MethodRename for syn::Ident {
114114

115115
impl MethodRename for &str {
116116
fn rename_method(&self, rule: &RenameRule) -> String {
117-
let s = self.to_string();
118-
119-
if MAGIC_METHOD.contains(&s.as_str()) {
120-
s
121-
} else {
122-
self.rename(rule)
117+
match rule {
118+
RenameRule::None => self.to_string(),
119+
_ => {
120+
if MAGIC_METHOD.contains(self) {
121+
if self == &MAGIC_METHOD[12] {
122+
"__toString".to_string()
123+
} else if self == &MAGIC_METHOD[16] {
124+
"__debugInfo".to_string()
125+
} else if self == &MAGIC_METHOD[3] {
126+
"__callStatic".to_string()
127+
} else {
128+
self.to_string()
129+
}
130+
} else {
131+
self.rename(rule)
132+
}
133+
}
123134
}
124135
}
125136
}

0 commit comments

Comments
 (0)