Description
I've been working on some wasmtime
code and that makes extensive use of proc macros to generate Rust code.
It means you can end up writing code like this:
wasmtime_wasi::p2::bindings::clocks::wall_clock::add_to_linker_get_host(l, closure)?;
You ctrl-click add_to_linker_get_host()
to read the code, and it takes you here:
#[proc_macro]
pub fn bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
bindgen::expand(&parse_macro_input!(input as bindgen::Config))
.unwrap_or_else(Error::into_compile_error)
.into()
}
That... sucks. I think Rust-analyzer could do better though because if you hover add_to_linker_get_host
it clearly knows about it:
This is maybe a better example. Hovering gives you great info about this type:
And you even get doc strings for members:
But if you ctrl-click the type you jump to exactly the same useless definition:
#[proc_macro]
pub fn bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
bindgen::expand(&parse_macro_input!(input as bindgen::Config))
.unwrap_or_else(Error::into_compile_error)
.into()
}
Would it be possible when you go-to-definition on these types to open an ephemeral editor and fill it with the generated code that the macro has written?
(Sorry if I'm not the first person to ask about this; I did try and search for duplicates but couldn't find any.)