Hello,
I'm writing a proc-macro plugin and I've had a hard time finding documentation (which makes sense, since it's all unstable AFAIK).
Is there a way to get the name of the file calling the macro, along with line number?
Now, I'm not 100% sure about my use of "proc-macro", what I mean is the following:
#[plugin_registrar]
pub fn registrar(reg: &mut Registry) {
reg.register_macro("blargblarg", expand_blargblarg);
}
fn expand_blargblarg(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) -> Box<MacResult + 'static> {
...
}
As far as I can tell, Span
contains the byte offset inside the file/translation-unit, but I really just need a line number.
I've thought about using a second macro_rules!
that wraps my proc macro and gives it the file!()
, line!()
and maybe col!()
, but I'm sure there's another way.