Skip to content

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

Merged
kyren merged 1 commit intokyren:masterfrom
Aaron1011:better-span
May 4, 2021
Merged

Use hygiene from Span::call_site() to produce error messages#13
kyren merged 1 commit intokyren:masterfrom
Aaron1011:better-span

Conversation

@Aaron1011
Copy link
Collaborator

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.

PR kyren#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
Copy link
Owner

kyren commented May 4, 2021

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.

@kyren kyren merged commit 76f89fc into kyren:master May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants