Skip to content

Convert Span to proc_macro::Span #35

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

Closed
antoyo opened this issue Dec 9, 2017 · 8 comments
Closed

Convert Span to proc_macro::Span #35

antoyo opened this issue Dec 9, 2017 · 8 comments

Comments

@antoyo
Copy link

antoyo commented Dec 9, 2017

Hi.
It would be useful to be able to convert a proc_macro2::Span to a proc_macro::Span.
For instance, this will allow to create Diagnostics with Span.
Thank you to add a From implementation for unstable only or something along these lines.

@alexcrichton
Copy link
Contributor

Ah yeah currently this isn't done b/c this is functionality which can only be implemented with the unstable feature enabled, but seems reasonable to implement in that case to me!

@antoyo
Copy link
Author

antoyo commented Dec 10, 2017

Either that or a function that returns Span::call_site() when the unstable feature is not enabled.
That will be very useful.
Thank you.

@mystor
Copy link
Contributor

mystor commented Dec 10, 2017

I have some WIP patches to add meaningful spans to the stable version of proc-macro2. It should allow us to expose those APIs from the span wrapper directly.

@alexcrichton
Copy link
Contributor

Oh nice! Sounds good to me @mystor

@SergioBenitez
Copy link
Contributor

SergioBenitez commented Dec 28, 2017

I've actually made these changes in my fork: https://github.com/SergioBenitez/proc-macro2. If these seem reasonable, @alexcrichton, I'd be happy to submit a PR.

@alexcrichton
Copy link
Contributor

There's some work for this at #36, with the conclusion at the end that what we should change is putting it behind an experimental feature.

@SergioBenitez
Copy link
Contributor

SergioBenitez commented Dec 30, 2017

The approach I've taken is a much simpler one: simply expose a method to retrieve a proc_macro::Span. This functionality is placed behind the "unstable" feature flag. Maybe we add another feature for this?

The reasoning here is that this approach relieves users of proc-macro2 from depending on the library being updated for each piece of new functionality introduced in the nightly proc-macro.

I don't have any issue with also exposing the shims in #36, however!

@alexcrichton
Copy link
Contributor

Added in #41

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

4 participants