Skip to content

Proc-macro: Rationalize function signature logic (transform_sig) #121

Closed
@taqtiqa-mark

Description

@taqtiqa-mark

Once proc-macro-attribute #[trace(...)] has test coverage and documentation covering the relevant code, it may be possible to simplify the logic within minitrace-macro/lib: transform_sig(...). Specifically, by eliminating these lines, (per this observation in PR #119):

for (i, arg) in sig.inputs.iter_mut().enumerate() {
match arg {
FnArg::Receiver(Receiver {
reference: Some(_), ..
}) => {}
FnArg::Receiver(arg) => arg.mutability = None,
FnArg::Typed(arg) => {
if let Pat::Ident(ident) = &mut *arg.pat {
ident.by_ref = None;
} else {
let positional = positional_arg(i, &arg.pat);
let m = mut_pat(&mut arg.pat);
arg.pat = parse_quote!(#m #positional);
}
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions