Call the right quote from parse_quote on sufficiently new compilers
diff --git a/src/export.rs b/src/export.rs
index cc7a222..8e270bd 100644
--- a/src/export.rs
+++ b/src/export.rs
@@ -8,6 +8,9 @@
pub use std::option::Option::{None, Some};
pub use std::result::Result::{Err, Ok};
+#[cfg(feature = "printing")]
+pub extern crate quote;
+
pub use proc_macro2::{Span, TokenStream as TokenStream2};
pub use span::IntoSpans;
diff --git a/src/parse_quote.rs b/src/parse_quote.rs
index e7c3dfe..93e2759 100644
--- a/src/parse_quote.rs
+++ b/src/parse_quote.rs
@@ -38,8 +38,14 @@
/// parameter `T` in the input generics.
///
/// ```
-/// #[macro_use]
-/// extern crate quote;
+#[cfg_attr(
+ not(syn_can_call_macro_by_path),
+ doc = " #[macro_use]"
+)]
+#[cfg_attr(
+ not(syn_can_call_macro_by_path),
+ doc = " extern crate quote;"
+)]
/// #[macro_use]
/// extern crate syn;
///
@@ -76,10 +82,29 @@
/// Panics if the tokens fail to parse as the expected syntax tree type. The
/// caller is responsible for ensuring that the input tokens are syntactically
/// valid.
-#[macro_export]
+#[macro_export(local_inner_macros)]
macro_rules! parse_quote {
($($tt:tt)*) => {
- $crate::parse_quote::parse($crate::export::From::from(quote!($($tt)*)))
+ $crate::parse_quote::parse($crate::export::From::from(quote_impl!($($tt)*)))
+ };
+}
+
+#[cfg(not(syn_can_call_macro_by_path))]
+#[doc(hidden)]
+#[macro_export]
+macro_rules! quote_impl {
+ ($($tt:tt)*) => {
+ // Require caller to have their own `#[macro_use] extern crate quote`.
+ quote!($($tt)*)
+ };
+}
+
+#[cfg(syn_can_call_macro_by_path)]
+#[doc(hidden)]
+#[macro_export]
+macro_rules! quote_impl {
+ ($($tt:tt)*) => {
+ $crate::export::quote::quote!($($tt)*)
};
}