Skip to content
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
21 changes: 12 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,24 +598,27 @@ fn gen_log(

// fn(a: usize, b: usize) => "a = {a:?}, b = {b:?}"
fn gen_input_format(sig: &Signature) -> String {
let mut input_format = String::new();
for (i, input) in sig.inputs.iter().enumerate() {
if i > 0 {
input_format.push_str(", ");
}
let mut args = vec![];

for input in &sig.inputs {
match input {
FnArg::Typed(PatType { pat, .. }) => {
if let Pat::Ident(pat_ident) = &**pat {
let ident = &pat_ident.ident;
input_format.push_str(&format!("{ident} = {{{ident}:?}}"));
let ident = &pat_ident.ident.to_string();
// Skip async-trait generated anonymous arguments.
Comment thread
andylokandy marked this conversation as resolved.
if ident.starts_with("__arg") {
continue;
}
args.push(format!("{ident} = {{{ident}:?}}"));
}
}
FnArg::Receiver(_) => {
input_format.push_str("self");
args.push("self".to_string());
}
}
}
input_format

Comment thread
andylokandy marked this conversation as resolved.
args.join(", ")
}

fn gen_output_format() -> String {
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/ok/async-trait-underscore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[async_trait::async_trait]
trait TestTrait {
async fn test(&self, value: String) -> String;
}

struct Test;

#[async_trait::async_trait]
impl TestTrait for Test {
#[logcall::logcall]
async fn test(&self, _: String) -> String {
"test".to_string()
}
}

fn main() {}
3 changes: 3 additions & 0 deletions tests/ui/ok/has-no-argument.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#[logcall::logcall]
fn f() {}

#[logcall::logcall]
fn g(_: i32) {}

fn main() {}