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

Investigate preserving comments #4

Open
dtolnay opened this issue Feb 14, 2019 · 1 comment
Open

Investigate preserving comments #4

dtolnay opened this issue Feb 14, 2019 · 1 comment

Comments

@dtolnay
Copy link

dtolnay commented Feb 14, 2019

This seems highly desirable for cargo crev's use case.

From each syn::ItemMod that gets parsed, you can find the Span of the semicolon and use Span::start from proc-macro2's "span-locations" feature to figure out the input file line and column of the semicolon. Then you can replace that semicolon character in the original source string with a set of braces containing an indented content of the child module. The final output would be a string of source code rather than syn::File, which the caller can parse to syn::File if they want.

@dtolnay
Copy link
Author

dtolnay commented Mar 3, 2019

FYI @dpc. This seems pretty necessary for crev-dev/cargo-crev#89 so you may be interested in giving it a shot.

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

No branches or pull requests

1 participant