mirror of
https://gitee.com/openharmony/third_party_rust_quote
synced 2024-11-23 23:29:43 +00:00
Add a feature for linking to proc_macro.
This feature is enabled by default for backwards compatibility, but it can be disabled in order to break the runtime dependency on the dynamic library libproc_macro in the rustc toolchain.
This commit is contained in:
parent
5a1b906e56
commit
7ef4822746
@ -10,3 +10,4 @@ rust:
|
||||
|
||||
script:
|
||||
- cargo test
|
||||
- cargo test --no-default-features
|
||||
|
@ -10,4 +10,10 @@ keywords = ["syn"]
|
||||
include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "0.3"
|
||||
proc-macro2 = { version = "0.3", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["proc-macro"]
|
||||
# Disabling the proc-macro feature removes the dynamic library dependency on
|
||||
# libproc_macro in the rustc compiler.
|
||||
proc-macro = ["proc-macro2/proc-macro"]
|
||||
|
@ -94,6 +94,7 @@
|
||||
#![doc(html_root_url = "https://docs.rs/quote/0.4.2")]
|
||||
|
||||
extern crate proc_macro2;
|
||||
#[cfg(feature = "proc-macro")]
|
||||
extern crate proc_macro;
|
||||
|
||||
mod tokens;
|
||||
@ -161,7 +162,10 @@ pub mod __rt {
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # #[cfg(feature = "proc-macro")]
|
||||
/// extern crate proc_macro;
|
||||
/// # #[cfg(not(feature = "proc-macro"))]
|
||||
/// # extern crate proc_macro2 as proc_macro;
|
||||
///
|
||||
/// #[macro_use]
|
||||
/// extern crate quote;
|
||||
|
@ -2,6 +2,7 @@ use super::ToTokens;
|
||||
use std::fmt::{self, Debug, Display};
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
#[cfg(feature = "proc-macro")]
|
||||
use proc_macro;
|
||||
use proc_macro2::{TokenStream, TokenTree};
|
||||
|
||||
@ -108,6 +109,7 @@ impl From<Tokens> for TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "proc-macro")]
|
||||
impl From<Tokens> for proc_macro::TokenStream {
|
||||
fn from(tokens: Tokens) -> proc_macro::TokenStream {
|
||||
TokenStream::from(tokens).into()
|
||||
|
Loading…
Reference in New Issue
Block a user