With modules, Rust identifier hygiene is (even more) weird
Every module, and the main template, turns into a separate macro_rules! macro. That means that Rust identifiers in template text from different sources, have different hygiene.
IOW this doesn't work:
define_derive_deftly_module! {
LetVariable:
${define LET_VARIABLE { let variable: i32 = 1; }}
}
define_derive_deftly! {
use LetVariable;
Trouble:
impl $ttype {
fn trouble() -> i32 {
${LET_VARIABLE}
variable
}
}
}
Also the error message is very confusing: it merely says there's no such thing in scope.
At the very least this should be documented, but it's very odd and perhaps derive-deftly should walk all of the imported definitions and set all of their identifier spans resolution to resolve at the final template site, with resolved_at. That would be a breaking change.