kyren / gc-arena

Incremental garbage collection from safe Rust
Creative Commons Zero v1.0 Universal
438 stars 36 forks source link

Use hygiene from `Span::call_site()` to produce error messages #13

Closed Aaron1011 closed 3 years ago

Aaron1011 commented 3 years ago

PR #12 used quote_spanned to make error messages have the span of the corresponding field in the struct. However, there's no indication that the error comes from #[derive(Collect)], which could be confusing for people unfamiliar with the crate.

This PR uses Span::resolved_at to give the generated spans the hygiene information from the call site. This causes rustc to add a note about the error message originating from a macro, while still keeping the error message at the proper location.

kyren commented 3 years ago

As far as I can tell, this makes sense to me. I feel a bit unqualified to be reviewing it properly but I think it makes sense.