Span
issues with FromStr
in unstable proc_macro
#48944
Labels
A-decl-macros-2-0
Area: Declarative macros 2.0 (#39412)
C-bug
Category: This is a bug.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
While writing improved tests for
proc_macro2
, I noticed some surprising behaviour of theFromStr
impl forproc_macro::TokenStream
.When parsing a string with
FromStr
, a token parsed from the very beginning of the string can have a differentsource_file()
than a token parsed elsewhere. For example:Will produce the output:
I would've expected both tokens to have the same context, and similar BytePos-es. Specifically I would have expected both of these tokens to have a span located in a fake ProcMacroSourceCode file, but set to resolve in the context of the enclosing scope (as if span.resolved_at(Span::call_site()) was called).
The text was updated successfully, but these errors were encountered: