dtolnay / watt

Runtime for executing procedural macros as WebAssembly
Apache License 2.0
1.29k stars 29 forks source link

Lex TokenStreams from within wasm #26

Closed mystor closed 5 years ago

mystor commented 5 years ago

This is a draft PR to use rustc_lexer to handle the FromStr implementation for TokenStream entirely within wasm (#18).

I'm pushing this up as a draft as I haven't run any tests on this implementation yet, nor have I benchmarked to see if it improves performance. Unfortunately I don't have a wa-serde-derive setup on my laptop right now, so it might be a bit before I get around to it.

In https://github.com/dtolnay/watt/issues/18#issue-515225393, it was suggested we could avoid parsing comments. I'm not sure that's possible, as macros can pass arbitrary strings into from_str, e.g. from a string literal, and we'd need to handle parsing them. If we decide not to support those callers some complexity could be eliminated by removing code related to doc comments.

mystor commented 5 years ago

Sounds like this doesn't provide a meaningful benefit, so I'll close the pr. Thanks for benchmarking @dtolnay