-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Consider providing meaningful Spans in stable implementation #27
Comments
@dtolnay If we provide a way to access these indices then I imagine I could use this instead of I'm not sure if we would want to expose that implementation detail which we could only expose from the stable half from What do you think @alexcrichton? |
Yeah I'm slightly wary of the wrt the intention that this crate just goes away in the future once I don't really mind hacking around it today though, we could have a Cargo feature that's basically flagged "this is unlikely to work in all situations, use at your own peril" |
I definitely don't want to export any APIs from proc-macro2 which we don't think are going to at the very least have equivalents in proc-macro before the new API is stable. I think we could potentially come up with an API for consuming spans (say If we come up with nice to use APIs, we could potentially contribute them back to proc-macro once rust-lang/rust#40939 has been merged. |
That seems plausible to me, yeah, but aren't there questions about where these contexts are stored and such? E.g. tls, handles, pointers, etc |
I think that the current api for That leaves 4 major options:
The first has the problem that now all code inside of The second has the same problem. So long as we let the caller control the I think that the only practical implementation option is either the third or the fourth, where the context is initialized when requested, and persists until the thread dies. That way we can make methods infallible, the API is relatively easy to use, and make it statically impossible to mix If a crate wants to clean up its Context objects, it'll have to use a new thread to do so, but that is probably worth it to avoid doing some implementation gymnastics to allow for threads to have multiple Contexts. |
Hm sorry I think I'm super lost now at this point. Want to just send a PR with what you're thinking? I don't really have many opinions here per-se, this crate is basically just a stopgap until |
I think the best way to do this would be for me to make a PR to rust-lang/rust after the new API lands with my suggested API, get feedback on it there, and then perhaps mirror it into proc_macro2 if feedback looks positive. I'd have to either implement a codemap inside of proc_macro2, or copy over the one I wrote for |
Makes sense to me! |
Implemented in #36. |
It looks like
cpp_syn
uses low and high indices into the input string like so:@mystor if we are able to provide the same thing here, would that eliminate the need for cpp_syn?
The text was updated successfully, but these errors were encountered: