Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use the consistent function name to duplicate #285

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pilota-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pilota-build"
version = "0.11.23"
version = "0.11.24"
edition = "2021"
description = "Compile thrift and protobuf idl into rust code at compile-time."
documentation = "https://docs.rs/pilota-build"
Expand Down
9 changes: 4 additions & 5 deletions pilota-build/src/parser/thrift/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,15 @@ impl ThriftLower {
service.name.to_upper_camel_case()
};

let mut function_names: FxHashMap<String, Vec<String>> = FxHashMap::default();
let mut function_names: FxHashMap<FastStr, Vec<String>> = FxHashMap::default();
service.functions.iter().for_each(|func| {
let name = self
.extract_tags(&func.annotations)
.get::<PilotaName>()
.map(|name| name.0.to_string())
.unwrap_or_else(|| func.name.to_string());
let ident = Ident::from(name.clone());
function_names
.entry(ident.to_upper_camel_case())
.entry(name.as_str().upper_camel_ident())
.or_default()
.push(name);
});
Expand Down Expand Up @@ -192,7 +191,7 @@ impl ThriftLower {
.map(|name| name.0.clone())
.unwrap_or_else(|| FastStr::new(f.name.0.clone()));

let upper_camel_ident = f.name.as_str().upper_camel_ident();
let upper_camel_ident = name.as_str().upper_camel_ident();
let method_name = if function_name_duplicates.contains(upper_camel_ident.as_str()) {
name
} else {
Expand Down Expand Up @@ -303,7 +302,7 @@ impl ThriftLower {
.map(|name| name.0.clone())
.unwrap_or_else(|| FastStr::new(method.name.0.clone()));

let upper_camel_ident = method.name.as_str().upper_camel_ident();
let upper_camel_ident = name.as_str().upper_camel_ident();
let method_name = if function_name_duplicates.contains(upper_camel_ident.as_str()) {
name
} else {
Expand Down
Loading