mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2025-02-17 05:27:46 +00:00
Rename unstable
feature to nightly
This commit is contained in:
parent
fa1864f185
commit
d66ecf6960
@ -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
|
||||
|
11
Cargo.toml
11
Cargo.toml
@ -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"]
|
||||
|
@ -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"] }
|
||||
```
|
||||
|
||||
|
||||
|
16
src/lib.rs
16
src/lib.rs
@ -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()
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user