Rename unstable feature to nightly

This commit is contained in:
David Tolnay 2018-01-02 20:05:42 -08:00
parent fa1864f185
commit d66ecf6960
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
5 changed files with 24 additions and 15 deletions

View File

@ -11,9 +11,9 @@ matrix:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
script:
- cargo test
- cargo build --features unstable
- cargo build --features nightly
- RUSTFLAGS='--cfg procmacro2_unstable' cargo test
- RUSTFLAGS='--cfg procmacro2_unstable' cargo build --features unstable
- RUSTFLAGS='--cfg procmacro2_unstable' cargo build --features nightly
- RUSTFLAGS='--cfg procmacro2_unstable' cargo doc --no-deps
after_success:
- travis-cargo --only nightly doc-upload

View File

@ -21,4 +21,13 @@ doctest = false
unicode-xid = "0.1"
[features]
unstable = []
# When enabled: act as a shim around the nightly compiler's proc_macro crate.
# This requires a nightly compiler.
#
# When disabled: emulate the same API as the nightly compiler's proc_macro crate
# but in a way that works on all stable compilers >=1.15.0.
nightly = []
# Deprecated; use "nightly" instead.
unstable = ["nightly"]

View File

@ -48,7 +48,7 @@ pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
}
```
If you'd like you can enable the `unstable` feature in this crate. This will
If you'd like you can enable the `nightly` feature in this crate. This will
cause it to compile against the **unstable and nightly-only** features of the
`proc_macro` crate. This in turn requires a nightly compiler. This should help
preserve span information, however, coming in from the compiler itself.
@ -57,7 +57,7 @@ You can enable this feature via:
```toml
[dependencies]
proc-macro2 = { version = "0.1", features = ["unstable"] }
proc-macro2 = { version = "0.1", features = ["nightly"] }
```

View File

@ -14,16 +14,16 @@
//! to use this crate will be trivially able to switch to the upstream
//! `proc_macro` crate once its API stabilizes.
//!
//! In the meantime this crate also has an `unstable` Cargo feature which
//! In the meantime this crate also has a `nightly` Cargo feature which
//! enables it to reimplement itself with the unstable API of `proc_macro`.
//! This'll allow immediate usage of the beneficial upstream API, particularly
//! around preserving span information.
#![cfg_attr(feature = "unstable", feature(proc_macro))]
#![cfg_attr(feature = "nightly", feature(proc_macro))]
extern crate proc_macro;
#[cfg(not(feature = "unstable"))]
#[cfg(not(feature = "nightly"))]
extern crate unicode_xid;
use std::fmt;
@ -31,14 +31,14 @@ use std::str::FromStr;
use std::iter::FromIterator;
#[macro_use]
#[cfg(not(feature = "unstable"))]
#[cfg(not(feature = "nightly"))]
mod strnom;
#[path = "stable.rs"]
#[cfg(not(feature = "unstable"))]
#[cfg(not(feature = "nightly"))]
mod imp;
#[path = "unstable.rs"]
#[cfg(feature = "unstable")]
#[cfg(feature = "nightly")]
mod imp;
#[macro_use]
@ -162,8 +162,8 @@ impl Span {
Span(imp::Span::def_site())
}
/// This method is only available when the `"unstable"` feature is enabled.
#[cfg(feature = "unstable")]
/// This method is only available when the `"nightly"` feature is enabled.
#[cfg(feature = "nightly")]
pub fn unstable(self) -> proc_macro::Span {
self.0.unstable()
}

View File

@ -6,7 +6,7 @@ use proc_macro2::{Term, Literal, TokenStream};
use proc_macro2::TokenNode;
#[cfg(procmacro2_unstable)]
#[cfg(not(feature = "unstable"))]
#[cfg(not(feature = "nightly"))]
use proc_macro2::Span;
#[test]
@ -121,7 +121,7 @@ testing 123
}
#[cfg(procmacro2_unstable)]
#[cfg(not(feature = "unstable"))]
#[cfg(not(feature = "nightly"))]
#[test]
fn default_span() {
let start = Span::call_site().start();