I just stumbled upon this:
impl<T> ToTokens for SpannedValue<T> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let mut group = proc_macro2::Group::new(proc_macro2::Delimiter::None, Default::default());
group.set_span(self.span);
tokens.append(group);
}
}
I.e., SpannedValue<T> always expands to an empty group. For something that's supposed to be a transparent wrapper, this is very surprising behavior. It should instead be:
impl<T: ToTokens> ToTokens for SpannedValue<T> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let mut group = proc_macro2::Group::new(proc_macro2::Delimiter::None, self.value.to_token_stream());
group.set_span(self.span);
tokens.append(group);
}
}
I do realize you may be abusing the ToTokens impl as a getter for the span through the Spanned blanket impl, but that's no good. You can provide a separate .span() method instead.
I just stumbled upon this:
I.e.,
SpannedValue<T>always expands to an empty group. For something that's supposed to be a transparent wrapper, this is very surprising behavior. It should instead be:I do realize you may be abusing the
ToTokensimpl as a getter for the span through theSpannedblanket impl, but that's no good. You can provide a separate.span()method instead.