Can proc-macro get the declaration of called function inside body?

pub fn hello() {
    let _ = Vec::new();

pub fn get_function_meta(_attr: TokenStream, input: TokenStream) -> TokenStream {
    // I can get the declaration of function `Vec::new` is `() -> Vec<T>`

I'm pretty sure that proc macros operate only on tokens and that they have no knowledge of the type system.

In that case it would be a syn::Stmt(Local(...)) all inside of the ItemFn.body. Here is a playground if you want to see the token tree. @alice is right type information is limited to what is already written in the code, there is no ability for a macro to infer types you'll need parts of the compiler for that.

@alice @DevinR528 Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.