Proc Macro over external files?

Alternative title: making include! writable out-of-tree.

Add a function proc_macro::TokenStream::read(File) -> io::Result<Self> or similar that reads in the contents of a file and parses it as a TokenStream with the correct Spans.

This would be invaluable for macros that want to process content from an external file (such as many declarative parsing frameworks), as generated names could then point back to their actual definition site in the case of a compiler error such as conflicting names.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.