I am writing a proc-macro and i require a canonical representation of an ident in the implementation.
Is this even possible to achieve without parsing the currently executed and running the name resolution algorithm from the call-site.
What do I mean with name-resolution
given the following code
my_proc!(hello_world);
I wish to canonicalise the hello_world. There are a few different scenarios i need to take into account here
fn hello_world () -> ! { ... }
my_proc!(hello_world); // canonicalises hello_world to crate::path::to::mod::hello_world; (even though hello_world is not pub i still require the full name as if it was pub based of the fact it will be used in a pre-processor stage
struct MyStruct;
impl MyStruct {
fn something() -> ! {
my_proc!(hello_world); // canonicalises to crate::path::to::mod::MyStruct::something::hello_world
fn hello_world() -> ! { ... }
}
}
struct MyStruct;
trait MyTrait { fn something () -> ! }
impl MyTrait for MyStruct {
fn something() -> ! {
let hello_world = "something";
use path::to::func as hello_world;
my_proc!(hello_world); // canonicalises to path::to::func
}
}
does a macro like my_proc exist or will i have to implement it myself ?