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(syn-solidity): set spans on generated struct names #336

Merged
merged 1 commit into from
Oct 6, 2023
Merged
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
16 changes: 12 additions & 4 deletions crates/sol-macro/src/expand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ impl<'ast> ExpCtxt<'ast> {
}

/// Returns the name of the function, adjusted for overloads.
fn function_name(&self, function: &ItemFunction) -> String {
self.overloaded_name(function.into()).as_string()
fn function_name(&self, function: &ItemFunction) -> SolIdent {
self.overloaded_name(function.into())
}

/// Returns the name of the given item, adjusted for overloads.
Expand All @@ -357,7 +357,11 @@ impl<'ast> ExpCtxt<'ast> {

/// Formats the given name as a function's call Rust struct name.
fn raw_call_name(&self, function_name: impl quote::IdentFragment + std::fmt::Display) -> Ident {
format_ident!("{function_name}Call")
let mut new_ident = format_ident!("{function_name}Call");
if let Some(span) = function_name.span() {
new_ident.set_span(span);
}
new_ident
}

/// Returns the name of the function's return Rust struct.
Expand All @@ -371,7 +375,11 @@ impl<'ast> ExpCtxt<'ast> {
&self,
function_name: impl quote::IdentFragment + std::fmt::Display,
) -> Ident {
format_ident!("{function_name}Return")
let mut new_ident = format_ident!("{function_name}Return");
if let Some(span) = function_name.span() {
new_ident.set_span(span);
}
new_ident
}

fn function_signature(&self, function: &ItemFunction) -> String {
Expand Down