This commit is a stab at getting the `proc_macro2` crate to function outside the
context of the compiler, **even when the `nightly` feature is enabled**.
Previously when the `nightly` feature was enabled then `proc_macro2` would panic
at runtime because `proc_macro` itself would panic at runtime due to the lack of
the compiler being initialized.
In this commit the `unstable` module in `proc_macro2` no longer unconditionally
uses the `proc_macro` upstream crate but is rather an `enum` over the upstream
crate and the `stable` module. At runtime the appropriate implementation is
dynamically selected depending on which works.
This brings up some uncomfortable issues such as what happens when you try to
psas a "stable span" to a "nightly `Literal`", but I think we can paper over
these issues in time by further canonicalizing everything to nightly/stable if
it comes up.
One caveat this brings up is that `Span::unstable` unconditionally panics when
outside the compiler, but I think that's expected regardless.
The stable/unstable modules still implemented the *very first* iteration of the
`proc_macro` API which has long since gone away. This tweaks notably the
`Literal` constructors to match what's proposed today, allowing lossless
conversions of literals on the stable implementation.
* Move storage of `Span` information on `Literal` and `Term` into the
stable/unstable layers as the unstable one will soon encompass this
* Remove `PartialEq` for `Span` as it's being replaced by an `eq` method.
This commit adds a feature to this crate which enables linking to the
upstream `proc_macro` crate. This should help this compile on targets
which don't have `proc_macro` and allow it to also be suitable for
embedding in Rust binaries.
This feature is turned on by default for backwards compatibility right
now.