diff --git a/README.md b/README.md index 5df4a9b..306974f 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,6 @@ This crate provides the `html!` macro for building HTML documents inside your Rust code using roughly [JSX] compatible syntax. -## Nightly Warning! - -This crate currently needs nightly rustc, and in order to use it you'll need to -add `#![feature(proc_macro_hygiene)]` to the top of your crate. The compiler -will tell you to do this if you forget. When this feature stabilises, the crate -should work on stable rustc without issues. - ## Quick Preview ```rust diff --git a/examples/wasm/src/main.rs b/examples/wasm/src/main.rs index 6082f93..cf3e1f4 100644 --- a/examples/wasm/src/main.rs +++ b/examples/wasm/src/main.rs @@ -1,5 +1,3 @@ -#![feature(proc_macro_hygiene)] - extern crate stdweb; extern crate typed_html; extern crate typed_html_macros; diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 282eb24..7b25539 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -18,6 +18,7 @@ proc-macro = true lalrpop-util = "0.16.1" ansi_term = "0.11.0" proc-macro2 = { version = "0.4.24", features = ["nightly"] } +proc-macro-hack = "0.5.1" quote = "0.6.10" [build-dependencies] diff --git a/macros/src/lib.rs b/macros/src/lib.rs index b5cb7af..fd5b315 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,14 +1,15 @@ #![recursion_limit = "128"] -#![feature(proc_macro_hygiene)] #![cfg_attr(can_show_location_of_runtime_parse_error, feature(proc_macro_span))] extern crate ansi_term; extern crate lalrpop_util; extern crate proc_macro; extern crate proc_macro2; +extern crate proc_macro_hack; extern crate quote; use proc_macro::TokenStream; +use proc_macro_hack::proc_macro_hack; mod config; mod declare; @@ -25,7 +26,7 @@ mod span; /// See the crate documentation for [`typed_html`][typed_html]. /// /// [typed_html]: ../typed_html/index.html -#[proc_macro] +#[proc_macro_hack] pub fn html(input: TokenStream) -> TokenStream { let stream = lexer::unroll_stream(input.into(), false); let result = html::expand_html(&stream); diff --git a/typed-html/Cargo.toml b/typed-html/Cargo.toml index 019e029..cb64c9a 100644 --- a/typed-html/Cargo.toml +++ b/typed-html/Cargo.toml @@ -23,3 +23,4 @@ language-tags = "0.2.2" http = "0.1.13" htmlescape = "0.3.1" stdweb = "0.4.10" +proc-macro-hack = "0.5.1" diff --git a/typed-html/src/dom.rs b/typed-html/src/dom.rs index c452e96..026375b 100644 --- a/typed-html/src/dom.rs +++ b/typed-html/src/dom.rs @@ -13,7 +13,6 @@ use htmlescape::encode_minimal; /// # Examples /// /// ``` -/// # #![feature(proc_macro_hygiene)] /// # use typed_html::html; /// # use typed_html::dom::DOMTree; /// # fn main() { diff --git a/typed-html/src/events.rs b/typed-html/src/events.rs index 77cfb80..9ed90bb 100644 --- a/typed-html/src/events.rs +++ b/typed-html/src/events.rs @@ -30,7 +30,6 @@ macro_rules! declare_events { /// # Examples /// /// ``` - /// # #![feature(proc_macro_hygiene)] /// # use typed_html::{html, for_events}; /// # use typed_html::dom::{DOMTree, VNode}; /// # fn main() { diff --git a/typed-html/src/lib.rs b/typed-html/src/lib.rs index 37f10a0..94e6061 100644 --- a/typed-html/src/lib.rs +++ b/typed-html/src/lib.rs @@ -1,17 +1,9 @@ //! This crate provides the `html!` macro for building HTML documents inside your //! Rust code using roughly [JSX] compatible syntax. //! -//! # Nightly Warning! -//! -//! This crate currently needs nightly rustc, and in order to use it you'll need to -//! add `#![feature(proc_macro_hygiene)]` to the top of your crate. The compiler -//! will tell you to do this if you forget. When this feature stabilises, the crate -//! should work on stable rustc without issues. -//! //! # Quick Preview //! //! ``` -//! # #![feature(proc_macro_hygiene)] //! # use typed_html::{html, for_events}; //! # use typed_html::dom::{DOMTree, VNode}; //! # use typed_html::types::Metadata; @@ -95,7 +87,6 @@ //! ## Example //! //! ``` -//! # #![feature(proc_macro_hygiene)] //! # use typed_html::html; //! # use typed_html::dom::DOMTree; //! # use typed_html::types::{Class, SpacedSet}; @@ -126,7 +117,6 @@ //! ## Example //! //! ``` -//! # #![feature(proc_macro_hygiene)] //! # use typed_html::{html, text}; //! # use typed_html::dom::DOMTree; //! # fn main() { @@ -154,7 +144,6 @@ //! ensure you're not using any event handlers that can't be printed. //! //! ``` -//! # #![feature(proc_macro_hygiene)] //! # use typed_html::html; //! # use typed_html::dom::DOMTree; //! # fn main() { @@ -208,11 +197,14 @@ pub extern crate htmlescape; extern crate http; extern crate language_tags; extern crate mime; +extern crate proc_macro_hack; extern crate stdweb; extern crate strum; extern crate typed_html_macros; -#[doc(inline)] +use proc_macro_hack::proc_macro_hack; + +#[proc_macro_hack] pub use typed_html_macros::html; pub mod dom;