Skip to content

Investigate preserving comments #4

@dtolnay

Description

@dtolnay

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions