Re: [PATCH v3 2/3] rust: macros: add macro to easily run KUnit tests

From: Boqun Feng
Date: Wed Oct 30 2024 - 01:17:10 EST


On Tue, Oct 29, 2024 at 10:11:38PM -0700, Boqun Feng wrote:
[...]
> > +
> > + let new_body: TokenStream = vec![body.stream(), kunit_macros.parse().unwrap()]
> > + .into_iter()
> > + .collect();
> > +
> > + // Remove the `#[test]` macros.
> > + let new_body = new_body.to_string().replace("#[test]", "");
>
> Yeah, I want to see how you do it this time ;-) So if you do a
> `.to_string()` on a `TokenStream`, you lose all the span [1] information
> ("span information" is a term invited by me, hope I get it right ;-))

Not important: I meant I am not a procdure macro expert, hope "span
information" is what is used when discussing span preservation ;-)

Regards,
Boqun

> e.g. if there is a compile error in the test code, the compiler cannot
> report the exact line of the error, it can only report there is an
> error.
>
[...]