-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid stringifying and reparsing a
TokenStream
This PR changes removes uses of the pattern `syn::parse_str(tokens.to_string())`, which loses `Span` information. In addition to making error messages less precise, it can break code that depends on the hygiene information carried by `Span`. Instead, `syn::parse_quote` is used to parse a `TokenStream` into the desired AST struct. I've added a test which demonstrates one of the problems with the previous code - using `$crate` would previously cause a panic, but now compiles successfully.
- Loading branch information
Showing
2 changed files
with
21 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters