While working on a late-pass clippy lint, I found that calling from_expansion
on string literal spans from built-in macros like stringify!
and include_str!
returns false
. Is there a more correct way to check if these spans came from a built-in macro expansion, or is this a bug in rustc
?
This query belongs in users.rust-lang.org (URLO); this IRLO forum is for proposed enhancements and/or changes to Rust's language and tooling.
I think this is fine here because it is directly relatted to compiler internals, and there wouldn't be enough people who know about that on users
5 Likes
Both stringify
and include_str
are buggy, and do not produce correct spans.
Some other built-in macros may be similarly buggy as well.
The fix is to create the output expression with span cx.with_def_site_ctxt(sp)
instead of just sp
.
The relevant code is in libsyntax_ext/source_util.rs
.
6 Likes
Thanks for the help. I'll work on a PR to fix it.
3 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.