Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce scope of quote_spanned on SerializeWith wrapper #2841

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Oct 22, 2024

This leaves more of the generated code accurately identified as generated, avoiding the dead_code and needless_lifetimes warnings that originated from #2558.

@Mingun
Copy link
Contributor

Mingun commented Oct 22, 2024

@dtolnay, for better understanding, could you explain, how this change fixes the warnings? rustc considers quote! code blocks as generated and quote_spanned! as not generated?

@dtolnay
Copy link
Member Author

dtolnay commented Oct 22, 2024

Tokens with a call_site span are understood as being macro-generated. It is not a difference between quote vs quote_spanned. Quote produces call_site spanned tokens, but if you passed a span to quote_spanned that happened to be call_site, then those tokens also would be considered generated despite coming from a quote_spanned expansion.

More precisely, the span's "resolution" being call_site is the thing that matters, as opposed to the span's "location" being call_site. So user_span.resolved_at(Span::call_site()) is generated while user_span.located_at(Span::call_site()) is not generated.

@dtolnay dtolnay merged commit 830309f into serde-rs:master Oct 22, 2024
15 checks passed
@dtolnay dtolnay deleted the serializewith branch October 22, 2024 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants