$crate being expanded too eagerly for nested macros


#1

Hey guys,

I’m having trouble figuring out a workaround to using $crate in a nested macro. Currently $crate is expanded when the parent macro is invoked, rather than leaving it to be expanded by the caller to the nested macro. For example: https://gist.github.com/petehayes102/6d71dee1240bd6ab8e5aa2067fd28249.

There has been a bit of discussion already about nested macro expansion (e.g. https://github.com/rust-lang/rust/issues/6994) and it seems a number of patches have been merged, but even on nightly I’m having the same issue. There was some talk of using $$ to escape nested macro variables, though that syntax produces an error, so I guess it wasn’t implemented.

Could someone shed some light on this for me?

Pete.